From 45e065bc4fc93731ea9a0543462bc7cf9e6084d7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 7 Jan 2009 15:59:57 +0000 Subject: Only two real changes. First, Bu::FString and Bu::FBasicString are in different files. This won't affect any programs at all anywhere. This will just make it easier to maintain and extend later. You still want to include "bu/fstring.h" and use Bu::FString in code. The other is kinda fun. I created a special format for unit tests, they use the extension .unit now and use the mkunit.sh script to convert them to c++ code. There are some nice features here too, maintaining unit tests is much, much easier, and we can have more features without making the code any harder to use. Also, it will be easier to have the unit tests generate reports and be run from a master program and the like. --- src/unit/array.cpp | 101 ----------------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 src/unit/array.cpp (limited to 'src/unit/array.cpp') diff --git a/src/unit/array.cpp b/src/unit/array.cpp deleted file mode 100644 index f7dc0ae..0000000 --- a/src/unit/array.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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/unitsuite.h" -#include "bu/hash.h" -#include "bu/array.h" - -class Unit : public Bu::UnitSuite -{ -public: - Unit() - { - setName("Array"); - addTest( Unit::general ); - addTest( Unit::iterate1 ); - addTest( Unit::iterate2 ); - addTest( Unit::copy ); - } - - virtual ~Unit() - { - } - - void general() - { - Bu::Array ai; - - ai.append( 5 ); - ai.append( 10 ); - unitTest( ai.getSize() == 2 ); - unitTest( ai.getCapacity() == 10 ); - unitTest( ai[0] == 5 ); - unitTest( ai[1] == 10 ); - } - - void iterate1() - { - Bu::Array ai; - for( int j = 0; j < 10; j++ ) - ai.append( j ); - - int j = 0; - for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) - unitTest( (*i) == j++ ); - - const Bu::Array &ci = ai; - j = 0; - for( Bu::Array::const_iterator i = ci.begin(); i != ci.end(); i++ ) - unitTest( (*i) == j++ ); - } - - void iterate2() - { - Bu::Array ai; - for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) - unitFailed("Empty lists shouldn't be iterated through."); - } - - void copy() - { - typedef Bu::Hash StrHash; - typedef Bu::Array StrHashArray; - - StrHash h1; - h1["Hi"] = "Yo"; - h1["Bye"] = "Later"; - - StrHash h2; - h2["Test"] = "Bloop"; - h2["Foo"] = "ooF"; - - StrHashArray a1; - a1.append( h1 ); - a1.append( h2 ); - - StrHashArray a2(a1); - - unitTest( a2[0].get("Hi") == "Yo" ); - unitTest( a2[0].get("Bye") == "Later" ); - unitTest( a2[1].get("Test") == "Bloop" ); - unitTest( a2[1].get("Foo") == "ooF" ); - - StrHashArray a3; - a3 = a1; - - unitTest( a3[0].get("Hi") == "Yo" ); - unitTest( a3[0].get("Bye") == "Later" ); - unitTest( a3[1].get("Test") == "Bloop" ); - unitTest( a3[1].get("Foo") == "ooF" ); - } -}; - -int main( int argc, char *argv[] ) -{ - return Unit().run( argc, argv ); -} - -- cgit v1.2.3