aboutsummaryrefslogtreecommitdiff
path: root/src/unit/substream.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/substream.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 '')
-rw-r--r--src/unit/substream.unit74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/unit/substream.unit b/src/unit/substream.unit
index 802ad4c..49817b0 100644
--- a/src/unit/substream.unit
+++ b/src/unit/substream.unit
@@ -9,44 +9,44 @@
9#include "bu/membuf.h" 9#include "bu/membuf.h"
10#include "bu/substream.h" 10#include "bu/substream.h"
11 11
12{=Init} 12suite SubStream
13
14{%testRead01}
15{ 13{
16 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz"); 14 test testRead01
17 mb.seek( 4 ); 15 {
18 Bu::SubStream ss( mb, 10 ); 16 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz");
19 unitTest( ss.readLine() == "efghijklmn" ); 17 mb.seek( 4 );
20} 18 Bu::SubStream ss( mb, 10 );
19 unitTest( ss.readLine() == "efghijklmn" );
20 }
21 21
22{%testRead02} 22 test testRead02
23{ 23 {
24 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz"); 24 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz");
25 mb.seek( 4 ); 25 mb.seek( 4 );
26 Bu::SubStream ss( mb, 10 ); 26 Bu::SubStream ss( mb, 10 );
27 char buf[8]; 27 char buf[8];
28 size_t iRead = ss.read( buf, 8 ); 28 size_t iRead = ss.read( buf, 8 );
29 unitTest( iRead == 8 ); 29 unitTest( iRead == 8 );
30 unitTest( strncmp( buf, "efghijkl", 8 ) == 0 ); 30 unitTest( strncmp( buf, "efghijkl", 8 ) == 0 );
31 unitTest( !ss.isEos() ); 31 unitTest( !ss.isEos() );
32 iRead = ss.read( buf, 8 ); 32 iRead = ss.read( buf, 8 );
33 unitTest( iRead == 2 ); 33 unitTest( iRead == 2 );
34 unitTest( strncmp( buf, "mn", 2 ) == 0 ); 34 unitTest( strncmp( buf, "mn", 2 ) == 0 );
35 unitTest( ss.isEos() ); 35 unitTest( ss.isEos() );
36} 36 }
37 37
38{%testRead03} 38 test testRead03
39{ 39 {
40 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz"); 40 Bu::MemBuf mb("abcdefghijklmnopqrstuvwxyz");
41 mb.seek( 20 ); 41 mb.seek( 20 );
42 Bu::SubStream ss( mb, 10 ); 42 Bu::SubStream ss( mb, 10 );
43 char buf[8]; 43 char buf[8];
44 size_t iRead = ss.read( buf, 8 ); 44 size_t iRead = ss.read( buf, 8 );
45 unitTest( iRead == 6 ); 45 unitTest( iRead == 6 );
46 unitTest( strncmp( buf, "uvwxyz", 6 ) == 0 ); 46 unitTest( strncmp( buf, "uvwxyz", 6 ) == 0 );
47 unitTest( ss.isEos() ); 47 unitTest( ss.isEos() );
48 iRead = ss.read( buf, 8 ); 48 iRead = ss.read( buf, 8 );
49 unitTest( iRead == 0 ); 49 unitTest( iRead == 0 );
50 unitTest( ss.isEos() ); 50 unitTest( ss.isEos() );
51 }
51} 52}
52