diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-08-13 16:14:53 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-08-13 16:14:53 +0000 |
commit | 3d5c548d630f8b6c86a250e1b7358824557ef01f (patch) | |
tree | 01bc0a81c7a9ae27209ca26e6ea5e0f09fb32dc5 /src/unit/list.unit | |
parent | 8e08c85cd77d7306fb3feaef8544778408c9d858 (diff) | |
download | libbu++-3d5c548d630f8b6c86a250e1b7358824557ef01f.tar.gz libbu++-3d5c548d630f8b6c86a250e1b7358824557ef01f.tar.bz2 libbu++-3d5c548d630f8b6c86a250e1b7358824557ef01f.tar.xz libbu++-3d5c548d630f8b6c86a250e1b7358824557ef01f.zip |
Ok, shared core looks good, and I added a unit test for Bu::List to check a few
basics. It works, so now I'm going to apply SharedCore to Bu::List and see how
bad it is.
Also, I got rid of all the warnings and things that showed up during
compilation, they were all silly anyway.
Finally, mkunit.sh is much cooler. Hard to believe it's a shell script, it now
also adds proper #line directives to the cpp output so if there is an error or
warning g++ will give you the right line number in your .unit file, not the
resultant cpp file.
Diffstat (limited to 'src/unit/list.unit')
-rw-r--r-- | src/unit/list.unit | 68 |
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 | |||
12 | typedef 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 | |||