コード例 #1
0
 def test_same(self):
     """Basic tests for all queens problem"""
     queen = AllQueens()
     self.assertFalse(queen.safe(1, 1, 1, 1))
コード例 #2
0
 def test_three_all(self):
     queen = AllQueens()
     self.assertEqual(queen.solve_all(3, 0, [], []), [])
コード例 #3
0
 def test_four_all(self):
     queen = AllQueens()
     solutions = queen.solve_all(4, 0, [], [])
     self.assertEqual(solutions, [[(0, 1), (1, 3), (2, 0),
                                   (3, 2)], [(0, 2), (1, 0), (2, 3),
                                             (3, 1)]])
コード例 #4
0
 def test_four_one(self):
     """Basic tests for all queens problem"""
     queen = AllQueens()
     self.assertEqual(queen.solve_one(4, 0, []), [(0, 1), (1, 3), (2, 0),
                                                  (3, 2)])
コード例 #5
0
 def test_one_all(self):
     queen = AllQueens()
     self.assertEqual(queen.solve_all(1, 0, [], []), [[(0, 0)]])
コード例 #6
0
 def test_one_one(self):
     """Basic tests for all queens problem"""
     queen = AllQueens()
     self.assertTrue(queen.solve_one(1, 0, []), [0, 0])
コード例 #7
0
 def test_two_one(self):
     """Basic tests for all queens problem"""
     queen = AllQueens()
     self.assertEqual(queen.solve_one(2, 0, []), [])
コード例 #8
0
 def test_multiple_safe(self):
     queen = AllQueens()
     self.assertTrue(queen.all_safe(1, 1, [(2, 3), (4, 5)]))
コード例 #9
0
 def test_multiple_unsafe(self):
     queen = AllQueens()
     self.assertFalse(queen.all_safe(1, 1, [(2, 3), (5, 5)]))
コード例 #10
0
 def test_one_placed_safe(self):
     queen = AllQueens()
     self.assertTrue(queen.all_safe(1, 1, [[2, 3]]))
コード例 #11
0
 def test_one_placed_unsafe(self):
     queen = AllQueens()
     self.assertFalse(queen.all_safe(1, 1, [(1, 1)]))
コード例 #12
0
 def test_no_placed(self):
     queen = AllQueens()
     self.assertTrue(queen.all_safe(1, 1, []))