Пример #1
0
 def test_check_BST_2(self):
     btree = {
         "root": [22, "A", "B"],
         "A": [20, "", "C"],
         "B": [25, "", ""],
         "C": [23, "", ""]
     }
     start = "root"
     result = quiz.check_BST(btree, start)
     self.assertIn(result, (True, False), "Result should be True or False")
     self.assertFalse(result, "Tree wasn't a BST, expected False")
Пример #2
0
 def test_check_BST_5(self):
     btree = {
         "root": [22, "A", ""],
         "A": [14, "B", ""],
         "B": [12, "C", "F"],
         "C": [11, "D", ""],
         "D": [10, "E", ""],
         "E": [9, "", ""],
         "F": [13, "", ""]
     }
     start = "root"
     result = quiz.check_BST(btree, start)
     self.assertIn(result, (True, False), "Result should be True or False")
     self.assertTrue(result, "Tree was a BST, expected True")
Пример #3
0
 def test_check_BST_4(self):
     btree = {
         "root": [22, "A", "B"],
         "A": [14, "C", "D"],
         "B": [33, "E", "F"],
         "C": [2, "", ""],
         "D": [17, "", ""],
         "E": [27, "", ""],
         "F": [45, "G", ""],
         "G": [32, "", ""]
     }
     start = "root"
     result = quiz.check_BST(btree, start)
     self.assertIn(result, (True, False), "Result should be True or False")
     self.assertIn(result, (True, False), "Result should be True or False")
     self.assertFalse(result, "Tree wasn't a BST, expected False")
Пример #4
0
 def test_check_BST_1(self):
     btree = {"root": [22, "", ""]}
     start = "root"
     result = quiz.check_BST(btree, start)
     self.assertIn(result, (True, False), "Result should be True or False")
     self.assertTrue(result, "Tree was a BST, expected True")