diff options
Diffstat (limited to 'src/tests/list.cpp')
-rw-r--r-- | src/tests/list.cpp | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/tests/list.cpp b/src/tests/list.cpp deleted file mode 100644 index aa3d32d..0000000 --- a/src/tests/list.cpp +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/list.h" | ||
9 | #include <list> | ||
10 | |||
11 | typedef struct Bob | ||
12 | { | ||
13 | int nID; | ||
14 | } Bob; | ||
15 | |||
16 | int main() | ||
17 | { | ||
18 | Bu::List<int> l; | ||
19 | |||
20 | l.append( 0 ); | ||
21 | |||
22 | for( int j = 3; j <= 21; j += 3 ) | ||
23 | { | ||
24 | l.append( j ); | ||
25 | l.prepend( -j ); | ||
26 | } | ||
27 | |||
28 | { | ||
29 | Bu::List<int>::iterator i = l.begin(); | ||
30 | Bu::List<int>::iterator j = i; | ||
31 | int a, b; | ||
32 | a = *j; | ||
33 | printf("end: %s\n", (j != l.end())?"no":"yes"); | ||
34 | j--; | ||
35 | printf("end: %s\n", (j != l.end())?"no":"yes"); | ||
36 | j++; | ||
37 | printf("end: %s\n", (j != l.end())?"no":"yes"); | ||
38 | i = j; | ||
39 | b = *i; | ||
40 | printf("%d -> %d\n", a, b ); | ||
41 | } | ||
42 | |||
43 | for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ ) | ||
44 | { | ||
45 | printf("%d ", *i ); | ||
46 | } | ||
47 | printf("\n"); | ||
48 | for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ ) | ||
49 | { | ||
50 | Bu::List<int>::iterator j = i; j--; | ||
51 | l.erase( i ); | ||
52 | i = j; | ||
53 | if( i != l.end() ) | ||
54 | printf("!%d ", *i ); | ||
55 | } | ||
56 | |||
57 | printf("\n\n"); | ||
58 | |||
59 | Bu::List<Bob> lb; | ||
60 | for( int j = 0; j < 10; j++ ) | ||
61 | { | ||
62 | Bob b; | ||
63 | b.nID = j; | ||
64 | lb.append( b ); | ||
65 | } | ||
66 | |||
67 | const Bu::List<Bob> rb = lb; | ||
68 | |||
69 | for( Bu::List<Bob>::const_iterator i = rb.begin(); i != rb.end(); i++ ) | ||
70 | { | ||
71 | //i->nID += 2; | ||
72 | //(*i).nID = 4; | ||
73 | printf("%d ", i->nID ); | ||
74 | } | ||
75 | printf("\n\n"); | ||
76 | } | ||
77 | |||