aboutsummaryrefslogtreecommitdiff
path: root/src/unit/membuf.unit
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-05-15 07:44:10 +0000
committerMike Buland <eichlan@xagasoft.com>2010-05-15 07:44:10 +0000
commit306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 (patch)
tree32c35f8507edb4ea403f4ebc4b625c1096f6f384 /src/unit/membuf.unit
parent11413d228bae2919fe69c83b74c7ff49209dd65a (diff)
downloadlibbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.gz
libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.bz2
libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.xz
libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.zip
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.
Diffstat (limited to 'src/unit/membuf.unit')
-rw-r--r--src/unit/membuf.unit61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/unit/membuf.unit b/src/unit/membuf.unit
index 883b7f8..1da3b90 100644
--- a/src/unit/membuf.unit
+++ b/src/unit/membuf.unit
@@ -8,38 +8,39 @@
8 8
9#include "bu/membuf.h" 9#include "bu/membuf.h"
10 10
11{=Init} 11suite MemBuf
12
13{%testWriteRead01}
14{ 12{
15 Bu::MemBuf mb; 13 test testWriteRead01
16 unitTest( mb.write("ab", 2 ) == 2 ); 14 {
17 unitTest( mb.write("cde", 3 ) == 3 ); 15 Bu::MemBuf mb;
18 unitTest( mb.write("FG", 2 ) == 2 ); 16 unitTest( mb.write("ab", 2 ) == 2 );
17 unitTest( mb.write("cde", 3 ) == 3 );
18 unitTest( mb.write("FG", 2 ) == 2 );
19 19
20 mb.setPos( 0 ); 20 mb.setPos( 0 );
21 21
22 char buf[8]; 22 char buf[8];
23 buf[7] = '\0'; 23 buf[7] = '\0';
24 unitTest( mb.read( buf, 7 ) == 7 ); 24 unitTest( mb.read( buf, 7 ) == 7 );
25 unitTest( !strncmp( buf, "abcdeFG", 7 ) ); 25 unitTest( !strncmp( buf, "abcdeFG", 7 ) );
26 unitTest( mb.read( buf, 7 ) == 0 ); 26 unitTest( mb.read( buf, 7 ) == 0 );
27 mb.seek( -3 ); 27 mb.seek( -3 );
28 unitTest( mb.read( buf, 7 ) == 3 ); 28 unitTest( mb.read( buf, 7 ) == 3 );
29 unitTest( !strncmp( buf, "eFG", 3 ) ); 29 unitTest( !strncmp( buf, "eFG", 3 ) );
30} 30 }
31 31
32{%testOverwrite1} 32 test testOverwrite1
33{ 33 {
34 Bu::MemBuf mb; 34 Bu::MemBuf mb;
35 unitTest( mb.write("0123456789") == 10 ); 35 unitTest( mb.write("0123456789") == 10 );
36 mb.setPos( 4 ); 36 mb.setPos( 4 );
37 unitTest( mb.write("-5-") == 3 ); 37 unitTest( mb.write("-5-") == 3 );
38 mb.setPos( 9 ); 38 mb.setPos( 9 );
39 mb.write("Hey!!!"); 39 mb.write("Hey!!!");
40 unitTest( mb.tell() == 15 ); 40 unitTest( mb.tell() == 15 );
41 char buf[50]; 41 char buf[50];
42 mb.setPos( 0 ); 42 mb.setPos( 0 );
43 buf[mb.read( buf, 50 )] = '\0'; 43 buf[mb.read( buf, 50 )] = '\0';
44 unitTest( !strcmp( buf, "0123-5-78Hey!!!" ) ); 44 unitTest( !strcmp( buf, "0123-5-78Hey!!!" ) );
45 }
45} 46}