aboutsummaryrefslogtreecommitdiff
path: root/src/tests/queuebuf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/queuebuf.cpp')
-rw-r--r--src/tests/queuebuf.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/tests/queuebuf.cpp b/src/tests/queuebuf.cpp
deleted file mode 100644
index f872738..0000000
--- a/src/tests/queuebuf.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 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/queuebuf.h>
9#include <bu/sio.h>
10
11using namespace Bu;
12
13int main()
14{
15 static const char *src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%#";
16 QueueBuf qb;
17
18 for( int j = 0; j < 8; j++ )
19 {
20 qb.write( src, 60 );
21 }
22
23 char buf[11], bufp[11];
24 while( !qb.isEos() )
25 {
26 int iAmntPeek = qb.peek( bufp, 9 );
27 int iAmntRead = qb.read( buf, 9 );
28 if( iAmntPeek != iAmntRead )
29 sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl;
30 buf[iAmntRead] = '\0';
31 bufp[iAmntPeek] = '\0';
32 if( memcmp( buf, bufp, iAmntPeek ) )
33 {
34 sio << "Buffers differ" << sio.nl
35 << " " << buf << sio.nl
36 << " " << bufp << sio.nl;
37 }
38 else
39 sio << "Read: >>" << buf << "<<" << sio.nl;
40 }
41
42 sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl;
43
44 for( int j = 0; j < 5; j++ )
45 {
46 qb.write( src, 25 );
47 qb.write( src+10, 25 );
48 }
49
50 char bufa[26];
51 char bufb[26];
52 ::memcpy( bufb, src+10, 15 );
53 ::memcpy( bufb+15, src+10, 10 );
54 bufb[25] = '\0';
55 sio << "Comparing to '" << bufb << "'" << sio.nl;
56 qb.seek( 10 );
57 while( !qb.isEos() )
58 {
59 bufa[qb.read( bufa, 25 )] = '\0';
60 qb.seek( 25 );
61 if( memcmp( bufa, bufb, 25 ) )
62 sio << "Differ?" << sio.nl;
63 sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl;
64 }
65}
66