aboutsummaryrefslogtreecommitdiff
path: root/src/unit/list.unit
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit/list.unit')
-rw-r--r--src/unit/list.unit68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/unit/list.unit b/src/unit/list.unit
new file mode 100644
index 0000000..9da0342
--- /dev/null
+++ b/src/unit/list.unit
@@ -0,0 +1,68 @@
1// vim: syntax=cpp
2/*
3 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
4 *
5 * This file is part of the libbu++ library and is released under the
6 * terms of the license contained in the file LICENSE.
7 */
8
9#include "bu/fstring.h"
10#include "bu/list.h"
11
12typedef Bu::List<int> IntList;
13
14{=Init}
15
16{%append}
17{
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 }
28}
29
30{%prepend}
31{
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 }
42}
43
44{%copy}
45{
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 }
67}
68