diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
commit | 306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 (patch) | |
tree | 32c35f8507edb4ea403f4ebc4b625c1096f6f384 /src/unit/list.unit | |
parent | 11413d228bae2919fe69c83b74c7ff49209dd65a (diff) | |
download | libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.gz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.bz2 libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.xz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.zip |
mkunit.sh was a little dumb, it didn't handle a number of things correctly.
I've written a new program that basically does the same thing, only it's much
more clever, and does many more of the translations and conversions better,
including the #line directives. Also, I dropped nids, we don't need it anymore.
But now I'm ready to write some serious tests for myriad.
Diffstat (limited to 'src/unit/list.unit')
-rw-r--r-- | src/unit/list.unit | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/src/unit/list.unit b/src/unit/list.unit index 0dd9f40..66e45b2 100644 --- a/src/unit/list.unit +++ b/src/unit/list.unit | |||
@@ -11,138 +11,138 @@ | |||
11 | 11 | ||
12 | typedef Bu::List<int> IntList; | 12 | typedef Bu::List<int> IntList; |
13 | 13 | ||
14 | {=Init} | 14 | suite List |
15 | |||
16 | {%append} | ||
17 | { | 15 | { |
18 | IntList lst; | 16 | test append |
19 | for( int j = 0; j < 50; j++ ) | ||
20 | { | ||
21 | lst.append( j ); | ||
22 | } | ||
23 | int j = 0; | ||
24 | for( IntList::iterator i = lst.begin(); i; i++, j++ ) | ||
25 | { | 17 | { |
26 | unitTest( *i == j ); | 18 | IntList lst; |
19 | for( int j = 0; j < 50; j++ ) | ||
20 | { | ||
21 | lst.append( j ); | ||
22 | } | ||
23 | int j = 0; | ||
24 | for( IntList::iterator i = lst.begin(); i; i++, j++ ) | ||
25 | { | ||
26 | unitTest( *i == j ); | ||
27 | } | ||
27 | } | 28 | } |
28 | } | ||
29 | 29 | ||
30 | {%prepend} | 30 | test prepend |
31 | { | ||
32 | IntList lst; | ||
33 | for( int j = 0; j < 50; j++ ) | ||
34 | { | 31 | { |
35 | lst.prepend( j ); | 32 | IntList lst; |
33 | for( int j = 0; j < 50; j++ ) | ||
34 | { | ||
35 | lst.prepend( j ); | ||
36 | } | ||
37 | int j = 49; | ||
38 | for( IntList::iterator i = lst.begin(); i; i++, j-- ) | ||
39 | { | ||
40 | unitTest( *i == j ); | ||
41 | } | ||
36 | } | 42 | } |
37 | int j = 49; | ||
38 | for( IntList::iterator i = lst.begin(); i; i++, j-- ) | ||
39 | { | ||
40 | unitTest( *i == j ); | ||
41 | } | ||
42 | } | ||
43 | 43 | ||
44 | {%copy} | 44 | test copy |
45 | { | ||
46 | IntList lst; | ||
47 | int j; | ||
48 | for( j = 0; j < 50; j++ ) | ||
49 | { | 45 | { |
50 | lst.append( j ); | 46 | IntList lst; |
47 | int j; | ||
48 | for( j = 0; j < 50; j++ ) | ||
49 | { | ||
50 | lst.append( j ); | ||
51 | } | ||
52 | IntList lst2 = lst; | ||
53 | |||
54 | j = 0; | ||
55 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | ||
56 | { | ||
57 | unitTest( *i == j ); | ||
58 | } | ||
59 | lst2.clear(); | ||
60 | lst2 = lst; | ||
61 | |||
62 | j = 0; | ||
63 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | ||
64 | { | ||
65 | unitTest( *i == j ); | ||
66 | } | ||
51 | } | 67 | } |
52 | IntList lst2 = lst; | ||
53 | 68 | ||
54 | j = 0; | 69 | test sort1 |
55 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | ||
56 | { | 70 | { |
57 | unitTest( *i == j ); | 71 | IntList lst; |
58 | } | ||
59 | lst2.clear(); | ||
60 | lst2 = lst; | ||
61 | 72 | ||
62 | j = 0; | 73 | lst.insertSorted( 5 ); |
63 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | 74 | lst.insertSorted( 1 ); |
64 | { | 75 | lst.insertSorted( 10 ); |
65 | unitTest( *i == j ); | 76 | lst.insertSorted( 3 ); |
66 | } | ||
67 | } | ||
68 | |||
69 | {%sort1} | ||
70 | { | ||
71 | IntList lst; | ||
72 | 77 | ||
73 | lst.insertSorted( 5 ); | 78 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); |
74 | lst.insertSorted( 1 ); | 79 | } |
75 | lst.insertSorted( 10 ); | ||
76 | lst.insertSorted( 3 ); | ||
77 | |||
78 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); | ||
79 | } | ||
80 | 80 | ||
81 | {%sort2} | 81 | test sort2 |
82 | { | 82 | { |
83 | IntList lst; | 83 | IntList lst; |
84 | 84 | ||
85 | lst.insertSorted<Bu::__basicGTCmp<int> >( 5 ); | 85 | lst.insertSorted<Bu::__basicGTCmp<int> >( 5 ); |
86 | lst.insertSorted<Bu::__basicGTCmp<int> >( 1 ); | 86 | lst.insertSorted<Bu::__basicGTCmp<int> >( 1 ); |
87 | lst.insertSorted<Bu::__basicGTCmp<int> >( 10 ); | 87 | lst.insertSorted<Bu::__basicGTCmp<int> >( 10 ); |
88 | lst.insertSorted<Bu::__basicGTCmp<int> >( 3 ); | 88 | lst.insertSorted<Bu::__basicGTCmp<int> >( 3 ); |
89 | 89 | ||
90 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); | 90 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); |
91 | } | 91 | } |
92 | 92 | ||
93 | {%sort3} | 93 | test sort3 |
94 | { | 94 | { |
95 | IntList lst; | 95 | IntList lst; |
96 | Bu::__basicGTCmp<int> cmp; | 96 | Bu::__basicGTCmp<int> cmp; |
97 | 97 | ||
98 | lst.insertSorted( cmp, 5 ); | 98 | lst.insertSorted( cmp, 5 ); |
99 | lst.insertSorted( cmp, 1 ); | 99 | lst.insertSorted( cmp, 1 ); |
100 | lst.insertSorted( cmp, 10 ); | 100 | lst.insertSorted( cmp, 10 ); |
101 | lst.insertSorted( cmp, 3 ); | 101 | lst.insertSorted( cmp, 3 ); |
102 | 102 | ||
103 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); | 103 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); |
104 | } | 104 | } |
105 | 105 | ||
106 | {%sort4} | 106 | test sort4 |
107 | { | 107 | { |
108 | IntList lst; | 108 | IntList lst; |
109 | 109 | ||
110 | lst.append( 5 ); | 110 | lst.append( 5 ); |
111 | lst.append( 1 ); | 111 | lst.append( 1 ); |
112 | lst.append( 10 ); | 112 | lst.append( 10 ); |
113 | lst.append( 3 ); | 113 | lst.append( 3 ); |
114 | 114 | ||
115 | lst.sort(); | 115 | lst.sort(); |
116 | 116 | ||
117 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); | 117 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); |
118 | } | 118 | } |
119 | 119 | ||
120 | {%sort5} | 120 | test sort5 |
121 | { | 121 | { |
122 | IntList lst; | 122 | IntList lst; |
123 | 123 | ||
124 | lst.append( 5 ); | 124 | lst.append( 5 ); |
125 | lst.append( 1 ); | 125 | lst.append( 1 ); |
126 | lst.append( 10 ); | 126 | lst.append( 10 ); |
127 | lst.append( 3 ); | 127 | lst.append( 3 ); |
128 | 128 | ||
129 | lst.sort<Bu::__basicGTCmp<int> >(); | 129 | lst.sort<Bu::__basicGTCmp<int> >(); |
130 | 130 | ||
131 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); | 131 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); |
132 | } | 132 | } |
133 | 133 | ||
134 | {%sort6} | 134 | test sort6 |
135 | { | 135 | { |
136 | IntList lst; | 136 | IntList lst; |
137 | 137 | ||
138 | lst.append( 5 ); | 138 | lst.append( 5 ); |
139 | lst.append( 1 ); | 139 | lst.append( 1 ); |
140 | lst.append( 10 ); | 140 | lst.append( 10 ); |
141 | lst.append( 3 ); | 141 | lst.append( 3 ); |
142 | 142 | ||
143 | Bu::__basicGTCmp<int> x; | 143 | Bu::__basicGTCmp<int> x; |
144 | lst.sort( x ); | 144 | lst.sort( x ); |
145 | 145 | ||
146 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); | 146 | unitTest( lst == IntList(10).append(5).append(3).append(1) ); |
147 | } | ||
147 | } | 148 | } |
148 | |||