diff options
Diffstat (limited to 'src/unit')
-rw-r--r-- | src/unit/membuf.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/unit/membuf.cpp b/src/unit/membuf.cpp index 3aebc4d..dc02aa3 100644 --- a/src/unit/membuf.cpp +++ b/src/unit/membuf.cpp | |||
@@ -15,6 +15,7 @@ public: | |||
15 | { | 15 | { |
16 | setName("MemBuf"); | 16 | setName("MemBuf"); |
17 | addTest( Unit::testWriteRead01 ); | 17 | addTest( Unit::testWriteRead01 ); |
18 | addTest( Unit::testOverwrite1 ); | ||
18 | } | 19 | } |
19 | 20 | ||
20 | virtual ~Unit() | 21 | virtual ~Unit() |
@@ -39,6 +40,21 @@ public: | |||
39 | unitTest( mb.read( buf, 7 ) == 3 ); | 40 | unitTest( mb.read( buf, 7 ) == 3 ); |
40 | unitTest( !strncmp( buf, "eFG", 3 ) ); | 41 | unitTest( !strncmp( buf, "eFG", 3 ) ); |
41 | } | 42 | } |
43 | |||
44 | void testOverwrite1() | ||
45 | { | ||
46 | Bu::MemBuf mb; | ||
47 | unitTest( mb.write("0123456789") == 10 ); | ||
48 | mb.setPos( 4 ); | ||
49 | unitTest( mb.write("-5-") == 3 ); | ||
50 | mb.setPos( 9 ); | ||
51 | mb.write("Hey!!!"); | ||
52 | unitTest( mb.tell() == 15 ); | ||
53 | char buf[50]; | ||
54 | mb.setPos( 0 ); | ||
55 | buf[mb.read( buf, 50 )] = '\0'; | ||
56 | unitTest( !strcmp( buf, "0123-5-78Hey!!!" ) ); | ||
57 | } | ||
42 | }; | 58 | }; |
43 | 59 | ||
44 | int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); } | 60 | int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); } |