forked from Atarity/2048-solver-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
30 lines (21 loc) · 747 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
import solverbot2048 as s2048
import snake
import numpy as np
class TestFuncTests(unittest.TestCase):
def test_getPerfectList(self):
self.assertEqual(s2048.getPerfectList([2, 4, 8, 4]), [2, 4, 8, 4])
self.assertEqual(s2048.getPerfectList([8, 4, 2, 4]), [8, 4, 4, 2])
def test_getPerfectDiff(self):
self.assertEqual(s2048.getPerfectDiff([2, 4, 8, 4]), 0)
self.assertEqual(s2048.getPerfectDiff([4, 2, 8, 4]), -5)
def test_snake(self):
a = np.ndarray((4,4), int)
s = snake.SnakeUnfolder(a)
siter = iter(s)
for i in range(4*4):
x,y = siter.nextcoords()
a[y,x] = i
print a
if __name__ == '__main__':
unittest.main()