diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
| commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
| tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/unit/list.unit | |
| parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
| download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip | |
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
| -rw-r--r-- | src/unit/list.unit | 264 |
1 files changed, 132 insertions, 132 deletions
diff --git a/src/unit/list.unit b/src/unit/list.unit index ec92fd5..0b60e43 100644 --- a/src/unit/list.unit +++ b/src/unit/list.unit | |||
| @@ -13,136 +13,136 @@ typedef Bu::List<int> IntList; | |||
| 13 | 13 | ||
| 14 | suite List | 14 | suite List |
| 15 | { | 15 | { |
| 16 | test append | 16 | test append |
| 17 | { | 17 | { |
| 18 | IntList lst; | 18 | IntList lst; |
| 19 | for( int j = 0; j < 50; j++ ) | 19 | for( int j = 0; j < 50; j++ ) |
| 20 | { | 20 | { |
| 21 | lst.append( j ); | 21 | lst.append( j ); |
| 22 | } | 22 | } |
| 23 | int j = 0; | 23 | int j = 0; |
| 24 | for( IntList::iterator i = lst.begin(); i; i++, j++ ) | 24 | for( IntList::iterator i = lst.begin(); i; i++, j++ ) |
| 25 | { | 25 | { |
| 26 | unitTest( *i == j ); | 26 | unitTest( *i == j ); |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | test prepend | 30 | test prepend |
| 31 | { | 31 | { |
| 32 | IntList lst; | 32 | IntList lst; |
| 33 | for( int j = 0; j < 50; j++ ) | 33 | for( int j = 0; j < 50; j++ ) |
| 34 | { | 34 | { |
| 35 | lst.prepend( j ); | 35 | lst.prepend( j ); |
| 36 | } | 36 | } |
| 37 | int j = 49; | 37 | int j = 49; |
| 38 | for( IntList::iterator i = lst.begin(); i; i++, j-- ) | 38 | for( IntList::iterator i = lst.begin(); i; i++, j-- ) |
| 39 | { | 39 | { |
| 40 | unitTest( *i == j ); | 40 | unitTest( *i == j ); |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | test copy | 44 | test copy |
| 45 | { | 45 | { |
| 46 | IntList lst; | 46 | IntList lst; |
| 47 | int j; | 47 | int j; |
| 48 | for( j = 0; j < 50; j++ ) | 48 | for( j = 0; j < 50; j++ ) |
| 49 | { | 49 | { |
| 50 | lst.append( j ); | 50 | lst.append( j ); |
| 51 | } | 51 | } |
| 52 | IntList lst2 = lst; | 52 | IntList lst2 = lst; |
| 53 | 53 | ||
| 54 | j = 0; | 54 | j = 0; |
| 55 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | 55 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) |
| 56 | { | 56 | { |
| 57 | unitTest( *i == j ); | 57 | unitTest( *i == j ); |
| 58 | } | 58 | } |
| 59 | lst2.clear(); | 59 | lst2.clear(); |
| 60 | lst2 = lst; | 60 | lst2 = lst; |
| 61 | 61 | ||
| 62 | j = 0; | 62 | j = 0; |
| 63 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) | 63 | for( IntList::iterator i = lst2.begin(); i; i++, j++ ) |
| 64 | { | 64 | { |
| 65 | unitTest( *i == j ); | 65 | unitTest( *i == j ); |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | test sort1 | 69 | test sort1 |
| 70 | { | 70 | { |
| 71 | IntList lst; | 71 | IntList lst; |
| 72 | 72 | ||
| 73 | lst.insertSorted( 5 ); | 73 | lst.insertSorted( 5 ); |
| 74 | lst.insertSorted( 1 ); | 74 | lst.insertSorted( 1 ); |
| 75 | lst.insertSorted( 10 ); | 75 | lst.insertSorted( 10 ); |
| 76 | lst.insertSorted( 3 ); | 76 | lst.insertSorted( 3 ); |
| 77 | 77 | ||
| 78 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); | 78 | unitTest( lst == IntList(1).append(3).append(5).append(10) ); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | test 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 | test 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 | test 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 | test 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 | test 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 | } |
