From 306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 15 May 2010 07:44:10 +0000 Subject: mkunit.sh was a little dumb, it didn't handle a number of things correctly. I've written a new program that basically does the same thing, only it's much more clever, and does many more of the translations and conversions better, including the #line directives. Also, I dropped nids, we don't need it anymore. But now I'm ready to write some serious tests for myriad. --- src/unit/array.unit | 121 ++++++++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 60 deletions(-) (limited to 'src/unit/array.unit') diff --git a/src/unit/array.unit b/src/unit/array.unit index ad249ef..1493033 100644 --- a/src/unit/array.unit +++ b/src/unit/array.unit @@ -9,76 +9,77 @@ #include "bu/hash.h" #include "bu/array.h" -{=Init} - -{%general} +suite Array { - Bu::Array ai; + test 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 ); -} + ai.append( 5 ); + ai.append( 10 ); + unitTest( ai.getSize() == 2 ); + unitTest( ai.getCapacity() == 10 ); + unitTest( ai[0] == 5 ); + unitTest( ai[1] == 10 ); + } -{%iterate1} -{ - Bu::Array ai; - for( int j = 0; j < 10; j++ ) - ai.append( j ); + test 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++ ); - unitTest( j == 10 ); - - const Bu::Array &ci = ai; - j = 0; - for( Bu::Array::const_iterator i = ci.begin(); i; i++ ) - unitTest( (*i) == j++ ); - unitTest( j == 10 ); -} + int j = 0; + for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) + unitTest( (*i) == j++ ); + unitTest( j == 10 ); + + const Bu::Array &ci = ai; + j = 0; + for( Bu::Array::const_iterator i = ci.begin(); i; i++ ) + unitTest( (*i) == j++ ); + unitTest( j == 10 ); + } -{%iterate2} -{ - Bu::Array ai; - for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) - unitFailed("Empty lists shouldn't be iterated through."); - for( Bu::Array::iterator i = ai.begin(); i; i++ ) - unitFailed("Empty lists shouldn't be iterated through."); -} + test iterate2 + { + Bu::Array ai; + for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) + unitFailed("Empty lists shouldn't be iterated through."); + for( Bu::Array::iterator i = ai.begin(); i; i++ ) + unitFailed("Empty lists shouldn't be iterated through."); + } -{%copy} -{ - typedef Bu::Hash StrHash; - typedef Bu::Array StrHashArray; + test copy + { + typedef Bu::Hash StrHash; + typedef Bu::Array StrHashArray; - StrHash h1; - h1["Hi"] = "Yo"; - h1["Bye"] = "Later"; + StrHash h1; + h1["Hi"] = "Yo"; + h1["Bye"] = "Later"; - StrHash h2; - h2["Test"] = "Bloop"; - h2["Foo"] = "ooF"; + StrHash h2; + h2["Test"] = "Bloop"; + h2["Foo"] = "ooF"; - StrHashArray a1; - a1.append( h1 ); - a1.append( h2 ); + StrHashArray a1; + a1.append( h1 ); + a1.append( h2 ); - StrHashArray a2(a1); + 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" ); + 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" ); + 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" ); + } } -- cgit v1.2.3