1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
562
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#SortTests
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
1076
|
9 |
category:'tests-Regression-Collections'
|
562
|
10 |
!
|
|
11 |
|
|
12 |
!SortTests class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
documentation to be added.
|
|
17 |
|
|
18 |
[author:]
|
1447
|
19 |
mb (mb@sixtyfour)
|
562
|
20 |
|
|
21 |
[instance variables:]
|
|
22 |
|
|
23 |
[class variables:]
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
|
|
27 |
"
|
|
28 |
! !
|
|
29 |
|
|
30 |
!SortTests methodsFor:'helpers'!
|
|
31 |
|
|
32 |
checkSort:data
|
|
33 |
|mergeSorted quickSorted definitivelySorted|
|
|
34 |
|
|
35 |
definitivelySorted := self goodSort:(data copy).
|
|
36 |
|
|
37 |
mergeSorted := data copy mergeSort.
|
|
38 |
self assert:(mergeSorted isSorted).
|
|
39 |
self assert:(mergeSorted = definitivelySorted).
|
|
40 |
|
1447
|
41 |
quickSorted := data copy quickSort.
|
562
|
42 |
self assert:(quickSorted isSorted).
|
|
43 |
self assert:(quickSorted = definitivelySorted).
|
|
44 |
!
|
|
45 |
|
|
46 |
goodSort:data
|
|
47 |
|tree|
|
|
48 |
|
|
49 |
tree := BinaryTree withAll:data.
|
|
50 |
^ tree asArray
|
|
51 |
! !
|
|
52 |
|
|
53 |
!SortTests methodsFor:'tests'!
|
|
54 |
|
|
55 |
test01_smallArrays
|
|
56 |
self checkSort: #(1 16 7 98 3 19 4 0).
|
|
57 |
self checkSort: #(1 16 7 98 9 3 19 4 0).
|
|
58 |
|
|
59 |
self checkSort: #(1 16 7 98 7 1 3 19 4 0).
|
|
60 |
self checkSort: #(1 16 7 98 7 1 3 19 4 0).
|
|
61 |
!
|
|
62 |
|
|
63 |
test02_largeArrays
|
|
64 |
|data|
|
|
65 |
|
|
66 |
data := (1 to:22581) collect:[:i | Random nextInteger] as:Array.
|
|
67 |
|
|
68 |
self checkSort: data.
|
|
69 |
! !
|
|
70 |
|
|
71 |
!SortTests class methodsFor:'documentation'!
|
|
72 |
|
|
73 |
version_CVS
|
|
74 |
^ '$Header$'
|
|
75 |
! !
|
1076
|
76 |
|