From 3d5c548d630f8b6c86a250e1b7358824557ef01f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 13 Aug 2009 16:14:53 +0000 Subject: 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. --- src/unit/list.unit | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/unit/list.unit (limited to 'src/unit') 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 @@ +// vim: syntax=cpp +/* + * Copyright (C) 2007-2008 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/fstring.h" +#include "bu/list.h" + +typedef Bu::List IntList; + +{=Init} + +{%append} +{ + IntList lst; + for( int j = 0; j < 50; j++ ) + { + lst.append( j ); + } + int j = 0; + for( IntList::iterator i = lst.begin(); i; i++, j++ ) + { + unitTest( *i == j ); + } +} + +{%prepend} +{ + IntList lst; + for( int j = 0; j < 50; j++ ) + { + lst.prepend( j ); + } + int j = 49; + for( IntList::iterator i = lst.begin(); i; i++, j-- ) + { + unitTest( *i == j ); + } +} + +{%copy} +{ + IntList lst; + int j; + for( j = 0; j < 50; j++ ) + { + lst.append( j ); + } + IntList lst2 = lst; + + j = 0; + for( IntList::iterator i = lst2.begin(); i; i++, j++ ) + { + unitTest( *i == j ); + } + lst2.clear(); + lst2 = lst; + + j = 0; + for( IntList::iterator i = lst2.begin(); i; i++, j++ ) + { + unitTest( *i == j ); + } +} + -- cgit v1.2.3