diff options
Diffstat (limited to 'src/tests/queuebuf.cpp')
-rw-r--r-- | src/tests/queuebuf.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/tests/queuebuf.cpp b/src/tests/queuebuf.cpp index accc723..677df16 100644 --- a/src/tests/queuebuf.cpp +++ b/src/tests/queuebuf.cpp | |||
@@ -13,11 +13,47 @@ int main() | |||
13 | qb.write( src, 60 ); | 13 | qb.write( src, 60 ); |
14 | } | 14 | } |
15 | 15 | ||
16 | char buf[11]; | 16 | char buf[11], bufp[11]; |
17 | while( !qb.isEos() ) | 17 | while( !qb.isEos() ) |
18 | { | 18 | { |
19 | buf[qb.read( buf, 9 )] = '\0'; | 19 | int iAmntPeek = qb.peek( bufp, 9 ); |
20 | sio << "Read: >>" << buf << "<<" << sio.nl; | 20 | int iAmntRead = qb.read( buf, 9 ); |
21 | if( iAmntPeek != iAmntRead ) | ||
22 | sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl; | ||
23 | buf[iAmntRead] = '\0'; | ||
24 | bufp[iAmntPeek] = '\0'; | ||
25 | if( memcmp( buf, bufp, iAmntPeek ) ) | ||
26 | { | ||
27 | sio << "Buffers differ" << sio.nl | ||
28 | << " " << buf << sio.nl | ||
29 | << " " << bufp << sio.nl; | ||
30 | } | ||
31 | else | ||
32 | sio << "Read: >>" << buf << "<<" << sio.nl; | ||
33 | } | ||
34 | |||
35 | sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl; | ||
36 | |||
37 | for( int j = 0; j < 5; j++ ) | ||
38 | { | ||
39 | qb.write( src, 25 ); | ||
40 | qb.write( src+10, 25 ); | ||
41 | } | ||
42 | |||
43 | char bufa[26]; | ||
44 | char bufb[26]; | ||
45 | ::memcpy( bufb, src+10, 15 ); | ||
46 | ::memcpy( bufb+15, src+10, 10 ); | ||
47 | bufb[25] = '\0'; | ||
48 | sio << "Comparing to '" << bufb << "'" << sio.nl; | ||
49 | qb.seek( 10 ); | ||
50 | while( !qb.isEos() ) | ||
51 | { | ||
52 | bufa[qb.read( bufa, 25 )] = '\0'; | ||
53 | qb.seek( 25 ); | ||
54 | if( memcmp( bufa, bufb, 25 ) ) | ||
55 | sio << "Differ?" << sio.nl; | ||
56 | sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl; | ||
21 | } | 57 | } |
22 | } | 58 | } |
23 | 59 | ||