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/list.unit | 206 ++++++++++++++++++++++++++--------------------------- 1 file changed, 103 insertions(+), 103 deletions(-) (limited to 'src/unit/list.unit') diff --git a/src/unit/list.unit b/src/unit/list.unit index 0dd9f40..66e45b2 100644 --- a/src/unit/list.unit +++ b/src/unit/list.unit @@ -11,138 +11,138 @@ typedef Bu::List IntList; -{=Init} - -{%append} +suite List { - IntList lst; - for( int j = 0; j < 50; j++ ) - { - lst.append( j ); - } - int j = 0; - for( IntList::iterator i = lst.begin(); i; i++, j++ ) + test append { - unitTest( *i == j ); + 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++ ) + test prepend { - lst.prepend( j ); + 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 ); + } } - 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++ ) + test copy { - lst.append( j ); + 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 ); + } } - IntList lst2 = lst; - j = 0; - for( IntList::iterator i = lst2.begin(); i; i++, j++ ) + test sort1 { - unitTest( *i == j ); - } - lst2.clear(); - lst2 = lst; + IntList lst; - j = 0; - for( IntList::iterator i = lst2.begin(); i; i++, j++ ) - { - unitTest( *i == j ); - } -} - -{%sort1} -{ - IntList lst; + lst.insertSorted( 5 ); + lst.insertSorted( 1 ); + lst.insertSorted( 10 ); + lst.insertSorted( 3 ); - lst.insertSorted( 5 ); - lst.insertSorted( 1 ); - lst.insertSorted( 10 ); - lst.insertSorted( 3 ); - - unitTest( lst == IntList(1).append(3).append(5).append(10) ); -} + unitTest( lst == IntList(1).append(3).append(5).append(10) ); + } -{%sort2} -{ - IntList lst; + test sort2 + { + IntList lst; - lst.insertSorted >( 5 ); - lst.insertSorted >( 1 ); - lst.insertSorted >( 10 ); - lst.insertSorted >( 3 ); + lst.insertSorted >( 5 ); + lst.insertSorted >( 1 ); + lst.insertSorted >( 10 ); + lst.insertSorted >( 3 ); - unitTest( lst == IntList(10).append(5).append(3).append(1) ); -} + unitTest( lst == IntList(10).append(5).append(3).append(1) ); + } -{%sort3} -{ - IntList lst; - Bu::__basicGTCmp cmp; + test sort3 + { + IntList lst; + Bu::__basicGTCmp cmp; - lst.insertSorted( cmp, 5 ); - lst.insertSorted( cmp, 1 ); - lst.insertSorted( cmp, 10 ); - lst.insertSorted( cmp, 3 ); + lst.insertSorted( cmp, 5 ); + lst.insertSorted( cmp, 1 ); + lst.insertSorted( cmp, 10 ); + lst.insertSorted( cmp, 3 ); - unitTest( lst == IntList(10).append(5).append(3).append(1) ); -} + unitTest( lst == IntList(10).append(5).append(3).append(1) ); + } -{%sort4} -{ - IntList lst; + test sort4 + { + IntList lst; - lst.append( 5 ); - lst.append( 1 ); - lst.append( 10 ); - lst.append( 3 ); + lst.append( 5 ); + lst.append( 1 ); + lst.append( 10 ); + lst.append( 3 ); - lst.sort(); + lst.sort(); - unitTest( lst == IntList(1).append(3).append(5).append(10) ); -} + unitTest( lst == IntList(1).append(3).append(5).append(10) ); + } -{%sort5} -{ - IntList lst; + test sort5 + { + IntList lst; - lst.append( 5 ); - lst.append( 1 ); - lst.append( 10 ); - lst.append( 3 ); + lst.append( 5 ); + lst.append( 1 ); + lst.append( 10 ); + lst.append( 3 ); - lst.sort >(); + lst.sort >(); - unitTest( lst == IntList(10).append(5).append(3).append(1) ); -} + unitTest( lst == IntList(10).append(5).append(3).append(1) ); + } -{%sort6} -{ - IntList lst; + test sort6 + { + IntList lst; - lst.append( 5 ); - lst.append( 1 ); - lst.append( 10 ); - lst.append( 3 ); + lst.append( 5 ); + lst.append( 1 ); + lst.append( 10 ); + lst.append( 3 ); - Bu::__basicGTCmp x; - lst.sort( x ); + Bu::__basicGTCmp x; + lst.sort( x ); - unitTest( lst == IntList(10).append(5).append(3).append(1) ); + unitTest( lst == IntList(10).append(5).append(3).append(1) ); + } } - -- cgit v1.2.3