From 3f1c8998166466245aee2860197fb4908e55f1a2 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 8 Oct 2008 16:17:26 +0000 Subject: Ok...corrected a problem with new block allocation in nids, and it no longer goes into an infinite loop while doing certain kinds of read. Also, it zeros out new blocks to make things easier to cope with in the hex editor, it'll probably also compress better. I also fixed Bu::MemBuf so that you can now write to arbitrary places mid-stream. --- src/unit/membuf.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/unit/membuf.cpp') 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: { setName("MemBuf"); addTest( Unit::testWriteRead01 ); + addTest( Unit::testOverwrite1 ); } virtual ~Unit() @@ -39,6 +40,21 @@ public: unitTest( mb.read( buf, 7 ) == 3 ); unitTest( !strncmp( buf, "eFG", 3 ) ); } + + void testOverwrite1() + { + Bu::MemBuf mb; + unitTest( mb.write("0123456789") == 10 ); + mb.setPos( 4 ); + unitTest( mb.write("-5-") == 3 ); + mb.setPos( 9 ); + mb.write("Hey!!!"); + unitTest( mb.tell() == 15 ); + char buf[50]; + mb.setPos( 0 ); + buf[mb.read( buf, 50 )] = '\0'; + unitTest( !strcmp( buf, "0123-5-78Hey!!!" ) ); + } }; int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); } -- cgit v1.2.3