diff options
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/list.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/list.cpp b/src/tests/list.cpp index 34ab656..12807a5 100644 --- a/src/tests/list.cpp +++ b/src/tests/list.cpp | |||
| @@ -1,4 +1,10 @@ | |||
| 1 | #include "bu/list.h" | 1 | #include "bu/list.h" |
| 2 | #include <list> | ||
| 3 | |||
| 4 | typedef struct Bob | ||
| 5 | { | ||
| 6 | int nID; | ||
| 7 | } Bob; | ||
| 2 | 8 | ||
| 3 | int main() | 9 | int main() |
| 4 | { | 10 | { |
| @@ -16,7 +22,32 @@ int main() | |||
| 16 | { | 22 | { |
| 17 | printf("%d ", *i ); | 23 | printf("%d ", *i ); |
| 18 | } | 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"); | ||
| 19 | 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 | } | ||
| 20 | printf("\n\n"); | 51 | printf("\n\n"); |
| 21 | } | 52 | } |
| 22 | 53 | ||
