Exemplo n.º 1
0
 def test_LightGrid_turnOn_2D_allLights_sequential(self):
     dimSizes = (3, 4)
     lg = lightGrid.LightGrid(dimSizes)
     for i in range(dimSizes[0]):
         for k in range(dimSizes[1]):
             lg.turnOn((i, k), (i, k))
             self.assertEqual((i * dimSizes[1] + k + 1), lg.onCount(), "i:{}, k:{}".format(i, k))
Exemplo n.º 2
0
 def test_LightGrid_toggle_1D_oneLightOn(self):
     lg = lightGrid.LightGrid((5,))
     lg.toggle((3,), (3,))
     self.assertEqual(1, lg.onCount())
Exemplo n.º 3
0
 def test_LightGrid_extrudeCorners_2D_truncateProtrudingY(self):
     lg = lightGrid.LightGrid((5, 5))
     c1, c2 = lg._extrudeCorners((2, -1), (2, 5))
     self.assertEqual((2, 0), c1, "Near Corner")
     self.assertEqual((2, 4), c2, "Far Corner")
Exemplo n.º 4
0
 def test_LightGrid_extrudeCorners_3D_extrude2D(self):
     lg = lightGrid.LightGrid((5, 5, 5))
     c1, c2 = lg._extrudeCorners((3, 1), (4, 2))
     self.assertEqual((3, 1, 0), c1, "Near Corner")
     self.assertEqual((4, 2, 4), c2, "Far Corner")
Exemplo n.º 5
0
 def test_LightGrid_init_onCount(self):
     lg = lightGrid.LightGrid()
     self.assertEqual(0, lg.onCount())
Exemplo n.º 6
0
 def test_LightGrid_init_asymmetricShrinking_bySize(self):
     lg = lightGrid.LightGrid((4, 3, 2))
     self.assertEqual([False] * 2, lg.grid[0][0])
Exemplo n.º 7
0
 def test_LightGrid_init_asymmetricGrowing_bySize(self):
     lg = lightGrid.LightGrid((2, 3, 4))
     self.assertEqual([False] * 4, lg.grid[0][0])
Exemplo n.º 8
0
 def test_LightGrid_turnOn_3D_allLight(self):
     lg = lightGrid.LightGrid((4, 4, 4))
     lg.turnOn((0, 0, 0), (4, 4, 4))
     self.assertEqual(64, lg.onCount())
Exemplo n.º 9
0
 def test_LightGrid_turnOn_1D_allLights_sequential(self):
     dimSize = 5
     lg = lightGrid.LightGrid((dimSize,))
     for i in range(dimSize):
         lg.turnOn((i,), (i,))
         self.assertEqual(i + 1, lg.onCount(), i + 1)
Exemplo n.º 10
0
 def test_LightGrid_turnOn_1D_allLights(self):
     lg = lightGrid.LightGrid((5,))
     lg.turnOn((0,), (4,))
     self.assertEqual(5, lg.onCount())
Exemplo n.º 11
0
 def test_LightGrid_toggle_2D_oneRow(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.toggle((4, 0), (4, 4))
     self.assertEqual(5, lg.onCount())
Exemplo n.º 12
0
 def test_LightGrid_toggle_2D_oneLight(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.toggle((3, 1), (3, 1))
     self.assertEqual(1, lg.onCount())
Exemplo n.º 13
0
 def test_LightGrid_init_v2_0D(self):
     lg = lightGrid.LightGrid([], version=2)
     self.assertEqual(0, lg.totalSum())
Exemplo n.º 14
0
 def test_LightGrid_toggle_2D_oneColumnDoubleToggle(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.toggle((0, 2), (4, 2))
     lg.toggle((0, 2), (4, 2))
     self.assertEqual(0, lg.onCount())
Exemplo n.º 15
0
 def test_LightGrid_toggle_1D_twoLightsDoubleToggle(self):
     lg = lightGrid.LightGrid((5,))
     lg.toggle((1,), (2,))
     lg.toggle((1,), (2,))
     self.assertEqual(0, lg.onCount())
Exemplo n.º 16
0
 def test_LightGrid_turnOn_2D_outOfRange_tooHighY(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.turnOn((2, 5), (3, 5))
     self.assertEqual(0, lg.onCount())
Exemplo n.º 17
0
 def test_LightGrid_init_asymmetricGrowing_byReference(self):
     lg = lightGrid.LightGrid((2, 3, 4))
     lg.grid[1][2][3] = True
     self.assertEqual(True, lg.grid[1][2][3])
Exemplo n.º 18
0
 def test_LightGrid_turnOn_1D_oneLight(self):
     dimSize = 5
     lg = lightGrid.LightGrid((dimSize,))
     lg.turnOn((3,), (3,))
     self.assertEqual(1, lg.onCount())
Exemplo n.º 19
0
 def test_LightGrid_turnOn_3D_allLight_emptyTuples(self):
     lg = lightGrid.LightGrid((5, 5, 5))
     lg.turnOn((), ())
     self.assertEqual(125, lg.onCount())
Exemplo n.º 20
0
 def test_LightGrid_turnOn_1D_twoLights(self):
     lg = lightGrid.LightGrid((5,))
     lg.turnOn((1,), (2,))
     self.assertEqual(2, lg.onCount())
Exemplo n.º 21
0
 def test_LightGrid_init_asymmetricShrinking_byReference(self):
     lg = lightGrid.LightGrid((4, 3, 2))
     lg.grid[3][2][1] = True
     self.assertEqual(True, lg.grid[3][2][1])
Exemplo n.º 22
0
 def test_LightGrid_init_1D_string(self):
     lg = lightGrid.LightGrid("30")
     self.assertEqual(0, lg.onCount())
Exemplo n.º 23
0
 def test_LightGrid_init_v2_default(self):
     lg = lightGrid.LightGrid(version=2)
     self.assertEqual((1000, 1000), lg.gridSize)
Exemplo n.º 24
0
 def test_LightGrid_turnOn_2D_oneColumnOn(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.turnOn((0, 2), (4, 2))
     self.assertEqual(5, lg.onCount())
Exemplo n.º 25
0
 def test_LightGrid_extrudeCorners_2D_truncate3D(self):
     lg = lightGrid.LightGrid((5, 5))
     c1, c2 = lg._extrudeCorners((3, 3, 3), (4, 4, 4))
     self.assertEqual((3, 3), c1, "Near Corner")
     self.assertEqual((4, 4), c2, "Far Corner")
Exemplo n.º 26
0
 def test_LightGrid_turnOn_2D_oneLightOn(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.turnOn((3, 1), (3, 1))
     self.assertEqual(1, lg.onCount())
Exemplo n.º 27
0
 def test_LightGrid_extrudeCorners_2D_truncateProtrudingX(self):
     lg = lightGrid.LightGrid((5, 5))
     c1, c2 = lg._extrudeCorners((-1, 2), (5, 2))
     self.assertEqual((0, 2), c1, "Near Corner")
     self.assertEqual((4, 2), c2, "Far Corner")
Exemplo n.º 28
0
 def test_LightGrid_turnOn_2D_oneRowOn(self):
     lg = lightGrid.LightGrid((5, 5))
     lg.turnOn((4, 0), (4, 4))
     self.assertEqual(5, lg.onCount())
Exemplo n.º 29
0
 def test_LightGrid_runInstructions_fTesta(self):
     lg = lightGrid.LightGrid()
     lg.readInstructions(self.fTesta)
     self.assertEqual(998996 , lg.onCount())
Exemplo n.º 30
0
 def test_LightGrid_toggle_1D_allLightOn(self):
     lg = lightGrid.LightGrid((5,))
     lg.toggle((0,), (4,))
     self.assertEqual(5, lg.onCount())