summaryrefslogtreecommitdiff
path: root/src/unit/membuf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit/membuf.cpp')
-rw-r--r--src/unit/membuf.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/unit/membuf.cpp b/src/unit/membuf.cpp
deleted file mode 100644
index dc02aa3..0000000
--- a/src/unit/membuf.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/unitsuite.h"
9#include "bu/membuf.h"
10
11class Unit : public Bu::UnitSuite
12{
13public:
14 Unit()
15 {
16 setName("MemBuf");
17 addTest( Unit::testWriteRead01 );
18 addTest( Unit::testOverwrite1 );
19 }
20
21 virtual ~Unit()
22 {
23 }
24
25 void testWriteRead01()
26 {
27 Bu::MemBuf mb;
28 unitTest( mb.write("ab", 2 ) == 2 );
29 unitTest( mb.write("cde", 3 ) == 3 );
30 unitTest( mb.write("FG", 2 ) == 2 );
31
32 mb.setPos( 0 );
33
34 char buf[8];
35 buf[7] = '\0';
36 unitTest( mb.read( buf, 7 ) == 7 );
37 unitTest( !strncmp( buf, "abcdeFG", 7 ) );
38 unitTest( mb.read( buf, 7 ) == 0 );
39 mb.seek( -3 );
40 unitTest( mb.read( buf, 7 ) == 3 );
41 unitTest( !strncmp( buf, "eFG", 3 ) );
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 }
58};
59
60int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); }