コード例 #1
0
 def test_unique_weights_stress_test(self):
     """
     Stress test finding a unique weight on a board with a large size.
     """
     bd = Board(500, 500)
     coord = [5, 15]
     weight = 51
     bd.setWeight(coord, weight)
     self.assertEqual(bd.isNodeWeightUnique(coord), True)
コード例 #2
0
 def test_unique_weights_true(self):
     """
     Tests to confirm positive result when node weight is unique.
     """
     bd = Board(30, 30)
     coord = [5, 15]
     weight = 85
     bd.setWeight(coord, weight)
     self.assertEqual(bd.isNodeWeightUnique(coord), True)
コード例 #3
0
 def test_unique_weights_false(self):
     """
     Tests to confirm negative result with more than 1 of the same weight across all nodes.
     """
     bd = Board(30, 30)
     coords = [[5, 15], [25, 3]]
     weight = 85
     for coord in coords:
         bd.setWeight(coord, weight)
     self.assertEqual(bd.isNodeWeightUnique(coords[0]), False)
コード例 #4
0
 def test_unique_weights(self):
     """
     Tests to confirm many weights can be unique on a board.
     """
     bd = Board(30, 30)
     weights = [60, 39, 67, 46, 61, 77, 62, 47, 13, 79, 66, 4, 58, 86, 49]
     coords = [[11, 21], [10, 22], [20, 26], [17, 3], [12, 13], [16, 13], [16, 3], [19, 29],\
      [27, 21], [13, 11], [18, 14], [2, 6], [26, 27], [12, 23], [28, 29]]
     for coord, weight in zip(coords, weights):
         bd.setWeight(coord, weight)
     for coord in coords:
         self.assertEqual(bd.isNodeWeightUnique(coord), True)
コード例 #5
0
 def test_unique_weights_50(self):
     """
     Test unique weights when all weights are 50.
     """
     bd = Board(30, 30)
     self.assertEqual(bd.isNodeWeightUnique([0, 0]), False)