<s> from nose . tools import assert_equal <EOL> class TestBinaryTree ( object ) : <EOL> def test_insert_traversals ( self ) : <EOL> myTree = BinaryTree ( ) <EOL> myTree2 = BinaryTree ( ) <EOL> for num in [ <NUM_LIT:50> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT> ] : <EOL> myTree . insert ( num ) <EOL> [ myTree2 . insert ( num ) for num in range ( <NUM_LIT:1> , <NUM_LIT:100> , <NUM_LIT:10> ) ] <EOL> print ( "<STR_LIT>" ) <EOL> expectVal = [ <NUM_LIT:7> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:50> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_equal ( myTree . printInOrder ( ) , expectVal ) <EOL> expectVal = [ <NUM_LIT:1> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_equal ( myTree2 . printInOrder ( ) , expectVal ) <EOL> print ( "<STR_LIT>" ) <EOL> expectVal = [ <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:50> ] <EOL> assert_equal ( myTree . printPostOrder ( ) , expectVal ) <EOL> expectVal = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:1> ] <EOL> assert_equal ( myTree2 . printPostOrder ( ) , expectVal ) <EOL> print ( "<STR_LIT>" ) <EOL> expectVal = [ <NUM_LIT:50> , <NUM_LIT:30> , <NUM_LIT:10> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_equal ( myTree . printPreOrder ( ) , expectVal ) <EOL> expectVal = [ <NUM_LIT:1> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_equal ( myTree2 . printPreOrder ( ) , expectVal ) <EOL> print ( "<STR_LIT>" ) <EOL> def test_max_min_nodes ( self ) : <EOL> myTree = BinaryTree ( ) <EOL> myTree . insert ( <NUM_LIT:5> ) <EOL> myTree . insert ( <NUM_LIT:1> ) <EOL> myTree . insert ( <NUM_LIT> ) <EOL> print ( "<STR_LIT>" ) <EOL> assert_equal ( myTree . maxNode ( ) , <NUM_LIT> ) <EOL> myTree . insert ( <NUM_LIT:32> ) <EOL> assert_equal ( myTree . maxNode ( ) , <NUM_LIT:32> ) <EOL> print ( "<STR_LIT>" ) <EOL> assert_equal ( myTree . minNode ( ) , <NUM_LIT:1> ) <EOL> print ( "<STR_LIT>" ) <EOL> myTree . insert ( - <NUM_LIT:10> ) <EOL> assert_equal ( myTree . minNode ( ) , - <NUM_LIT:10> ) <EOL> print ( "<STR_LIT>" ) <EOL> def test_delete ( self ) : <EOL> myTree = BinaryTree ( ) <EOL> myTree . insert ( <NUM_LIT:5> ) <EOL> print ( "<STR_LIT>" ) <EOL> myTree . delete ( <NUM_LIT:5> ) <EOL> assert_equal ( myTree . treeIsEmpty ( ) , True ) <EOL> print ( "<STR_LIT>" ) <EOL> [ myTree . insert ( x ) for x in range ( <NUM_LIT:1> , <NUM_LIT:5> ) ] <EOL> myTree . delete ( <NUM_LIT:2> ) <EOL> assert_equal ( myTree . root . rightChild . data , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" ) <EOL> assert_equal ( myTree . delete ( <NUM_LIT:100> ) , False ) <EOL> print ( "<STR_LIT>" ) <EOL> def main ( ) : <EOL> testing = TestBinaryTree ( ) <EOL> testing . test_insert_traversals ( ) <EOL> testing . test_max_min_nodes ( ) <EOL> testing . test_delete ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
