示例#1
0
 def test_pos2line(self):
     lm = LineMaker([2,2], 6)
     line = lm._pos2line([0,0])
     self.assertEqual(line, [BK,BK,WT,BK,BK,WT])
     line = lm._pos2line([1,0])
     self.assertEqual(line, [WT,BK,BK,WT,BK,BK])
     line = lm._pos2line([0,1])
     self.assertEqual(line, [BK,BK,WT,WT,BK,BK])
示例#2
0
 def test_next(self):
     lm = LineMaker([1], 2)
     expect = [[BK,WT],
               [WT,BK]
               ]
     while expect:
         self.assertEqual(lm.next(), expect.pop(0))
     self.assertEqual(lm.next(), None)
示例#3
0
 def test_postotal(self):
     data = [[[1], 1, 0],
             [[1], 2, 1],
             [[2], 3, 1],
             [[1,1], 3, 0],
             [[1,1], 4, 1],
             [[2,3], 8, 2],
             [[3,2,2], 10, 1],
             [[1,1,1], 5, 0]
             ]
     while data:
         prof, width, expect = data.pop(0)
         lm = LineMaker(prof, width)
         self.assertEqual(lm._postotal(), expect)
示例#4
0
 def test_next39(self):        
     lm = LineMaker([2,1,2], 9)
     expect = [[BK,BK,WT,BK,WT,BK,BK,WT,WT],
               [WT,BK,BK,WT,BK,WT,BK,BK,WT],
               [WT,WT,BK,BK,WT,BK,WT,BK,BK],
               [BK,BK,WT,WT,BK,WT,BK,BK,WT],
               [WT,BK,BK,WT,WT,BK,WT,BK,BK],
               [BK,BK,WT,WT,WT,BK,WT,BK,BK],
               [BK,BK,WT,BK,WT,WT,BK,BK,WT],
               [WT,BK,BK,WT,BK,WT,WT,BK,BK],
               [BK,BK,WT,WT,BK,WT,WT,BK,BK],
               [BK,BK,WT,BK,WT,WT,WT,BK,BK],
               ]
     while expect:
         self.assertEqual(lm.next(), expect.pop(0))
     self.assertEqual(lm.next(), None)