diff options
Diffstat (limited to 'src/tests/list.cpp')
-rw-r--r-- | src/tests/list.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/list.cpp b/src/tests/list.cpp new file mode 100644 index 0000000..12807a5 --- /dev/null +++ b/src/tests/list.cpp | |||
@@ -0,0 +1,53 @@ | |||
1 | #include "bu/list.h" | ||
2 | #include <list> | ||
3 | |||
4 | typedef struct Bob | ||
5 | { | ||
6 | int nID; | ||
7 | } Bob; | ||
8 | |||
9 | int main() | ||
10 | { | ||
11 | Bu::List<int> l; | ||
12 | |||
13 | l.append( 0 ); | ||
14 | |||
15 | for( int j = 3; j <= 21; j += 3 ) | ||
16 | { | ||
17 | l.append( j ); | ||
18 | l.prepend( -j ); | ||
19 | } | ||
20 | |||
21 | for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ ) | ||
22 | { | ||
23 | printf("%d ", *i ); | ||
24 | } | ||
25 | printf("\n"); | ||
26 | for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ ) | ||
27 | { | ||
28 | l.erase( i ); | ||
29 | if( i != l.end() ) | ||
30 | printf("%d ", *i ); | ||
31 | } | ||
32 | |||
33 | printf("\n\n"); | ||
34 | |||
35 | Bu::List<Bob> lb; | ||
36 | for( int j = 0; j < 10; j++ ) | ||
37 | { | ||
38 | Bob b; | ||
39 | b.nID = j; | ||
40 | lb.append( b ); | ||
41 | } | ||
42 | |||
43 | const Bu::List<Bob> rb = lb; | ||
44 | |||
45 | for( Bu::List<Bob>::const_iterator i = rb.begin(); i != rb.end(); i++ ) | ||
46 | { | ||
47 | //i->nID += 2; | ||
48 | //(*i).nID = 4; | ||
49 | printf("%d ", i->nID ); | ||
50 | } | ||
51 | printf("\n\n"); | ||
52 | } | ||
53 | |||