--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__BinaryTreeTester.st Wed Dec 10 10:54:15 2003 +0100
@@ -0,0 +1,179 @@
+"{ Package: 'exept:regression' }"
+
+TestCase subclass:#BinaryTreeTester
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Ordered'
+!
+
+!BinaryTreeTester class methodsFor:'documentation'!
+
+documentation
+"
+ documentation to be added.
+
+ [author:]
+ Claus Gittinger (cg@alan)
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+!
+
+history
+ "Created: / 9.12.2003 / 19:34:33 / cg"
+! !
+
+!BinaryTreeTester methodsFor:'initialize / release'!
+
+setUp
+ "common setup - invoked before testing."
+
+ super setUp
+!
+
+tearDown
+ "common cleanup - invoked after testing."
+
+ super tearDown
+! !
+
+!BinaryTreeTester methodsFor:'tests'!
+
+exhaustive_test03_removing
+ |bt|
+
+ #(10 9 8 7 6 5 4 3 2 1) permutationsDo:[:sequenceToRemoveElements |
+ bt := BinaryTree new.
+ bt addAll:#(1 2 3 4 5 6 7 8 9 10).
+
+
+ sequenceToRemoveElements do:[:each |
+ bt remove:each.
+ self assert: ( bt includes:each ) not.
+ ].
+ self assert: ( bt size == 0 ).
+
+ sequenceToRemoveElements do:[:each |
+ bt add:each.
+ self assert: ( bt includes:each ).
+ ].
+ self assert: ( bt size == 10 ).
+ ].
+
+ "
+ self run:#exhaustive_test03_removing
+ self new exhaustive_test03_removing
+ "
+!
+
+test01_empty
+ |bt|
+
+ bt := BinaryTree new.
+ self assert: ( bt size == 0 ).
+ self assert: ( bt isEmpty ).
+ self assert: ( bt asArray = #() ).
+
+ "
+ self run:#test01_empty
+ self new test01_empty
+ "
+!
+
+test02_adding
+ |bt|
+
+ bt := BinaryTree new.
+
+ bt add:1.
+ self assert: ( bt size == 1 ).
+ self assert: ( bt notEmpty ).
+ self assert: ( bt asArray = #(1) ).
+
+ bt add:2.
+ self assert: ( bt size == 2 ).
+ self assert: ( bt asArray = #(1 2) ).
+
+ bt addAll:#(3 4 5 6 7 8 9 10).
+ self assert: ( bt size == 10 ).
+ self assert: ( bt asArray = #(1 2 3 4 5 6 7 8 9 10) ).
+
+ "
+ self run:#test02_adding
+ self new test02_adding
+ "
+!
+
+test03_removing
+ |bt|
+
+ bt := BinaryTree new.
+ bt addAll:#(1 2 3 4 5 6 7 8 9 10).
+
+ self assert: ( bt size == 10 ).
+ self assert: ( bt asArray = #(1 2 3 4 5 6 7 8 9 10) ).
+
+ #(4 2 1 3 5 6) do:[:toRemove |
+ |t|
+
+ bt := BinaryTree new.
+ bt addAll:#(1 2 3 4 5 6 7 8 9 10).
+
+ bt remove:toRemove.
+ self assert: ( bt includes:toRemove ) not.
+ self assert: ( bt size == 9 ).
+
+ t := #(1 2 3 4 5 6 7 8 9 10) asOrderedCollection.
+ t remove:toRemove.
+
+ self assert:( bt asArray = t asArray ).
+ ].
+
+ "
+ self run:#test03_removing
+ self new test03_removing
+ "
+!
+
+test04_addingRemoving
+ |allSelectors bt|
+
+ allSelectors := OrderedCollection new.
+ Smalltalk allClassesDo:[:cls |
+ cls instAndClassSelectorsAndMethodsDo:[:sel :mthd |
+ allSelectors add:sel.
+ ].
+ ].
+
+ bt := BinaryTree new.
+ allSelectors do:[:sel |
+ bt add:sel
+ ].
+ self assert:(bt size == allSelectors size).
+
+ allSelectors do:[:sel |
+ self assert:(bt includesIdentical:sel)
+ ].
+
+ allSelectors do:[:sel |
+ bt removeIdentical:sel
+ ].
+ self assert:(bt isEmpty).
+
+ "
+ self run:#test04_addingRemoving
+ self new test04_addingRemoving
+ "
+! !
+
+!BinaryTreeTester class methodsFor:'documentation'!
+
+version
+ ^ '$Header$'
+! !