aboutsummaryrefslogtreecommitdiff
path: root/src/unit/membuf.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
commitac517a2b7625e0aa0862679e961c6349f859ea3b (patch)
treee3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/unit/membuf.cpp
parentf8d4301e9fa4f3709258505941e37fab2eadadc6 (diff)
parentbd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff)
downloadlibbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to '')
-rw-r--r--src/unit/membuf.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/unit/membuf.cpp b/src/unit/membuf.cpp
new file mode 100644
index 0000000..65ba82a
--- /dev/null
+++ b/src/unit/membuf.cpp
@@ -0,0 +1,37 @@
1#include "bu/unitsuite.h"
2#include "bu/membuf.h"
3
4class Unit : public Bu::UnitSuite
5{
6public:
7 Unit()
8 {
9 setName("MemBuf");
10 addTest( Unit::testWriteRead01 );
11 }
12
13 virtual ~Unit()
14 {
15 }
16
17 void testWriteRead01()
18 {
19 Bu::MemBuf mb;
20 unitTest( mb.write("ab", 2 ) == 2 );
21 unitTest( mb.write("cde", 3 ) == 3 );
22 unitTest( mb.write("FG", 2 ) == 2 );
23
24 mb.setPos( 0 );
25
26 char buf[8];
27 buf[7] = '\0';
28 unitTest( mb.read( buf, 7 ) == 7 );
29 unitTest( !strncmp( buf, "abcdeFG", 7 ) );
30 unitTest( mb.read( buf, 7 ) == 0 );
31 mb.seek( -3 );
32 unitTest( mb.read( buf, 7 ) == 3 );
33 unitTest( !strncmp( buf, "eFG", 3 ) );
34 }
35};
36
37int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); }