summaryrefslogtreecommitdiff
path: root/src/tests/nids.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/nids.cpp')
-rw-r--r--src/tests/nids.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/tests/nids.cpp b/src/tests/nids.cpp
index f50fde5..d531280 100644
--- a/src/tests/nids.cpp
+++ b/src/tests/nids.cpp
@@ -4,22 +4,44 @@
4 4
5int main( int argc, char *argv[] ) 5int main( int argc, char *argv[] )
6{ 6{
7 if( argc < 2 ) 7 if( argc < 3 )
8 { 8 {
9 printf("usage: %s <output>\n\n", argv[0] ); 9 printf("usage: %s [r|w] <output>\n\n", argv[0] );
10 return 1; 10 return 1;
11 } 11 }
12 12
13 Bu::File fOut( argv[1], Bu::File::ReadWrite ); 13 if( argv[1][0] == 'w' )
14 Bu::Nids n( fOut ); 14 {
15 Bu::File fOut( argv[2],
16 Bu::File::ReadWrite|Bu::File::Create|Bu::File::Truncate );
17 Bu::Nids n( fOut );
15 18
16// n.initialize( 120, 5 ); 19 n.initialize( 120, 1 );
20 Bu::NidsStream s = n.openStream( n.createStream() );
17 21
18 Bu::NidsStream s = n.openStream( n.createStream() ); 22 Bu::FString sBuf( 350 );
23 memset( sBuf.getStr(), 'a', 350 );
24 s.write( sBuf );
25 }
26 else if( argv[1][0] == 'r' )
27 {
28 Bu::File fOut( argv[2], Bu::File::Read );
29 Bu::Nids n( fOut );
19 30
20// Bu::FString sBuf( 350 ); 31 Bu::NidsStream s = n.openStream( 0 );
21// memset( sBuf.getStr(), 'a', 350 ); 32 char buf[75];
22// s.write( sBuf ); 33 for( int j = 0; j < 3; j++ )
34 {
35 int iRead = s.read( buf, 75 );
36 fwrite( buf, 1, iRead, stdout );
37 printf("\n(read %d chars)\n", iRead );
38 }
39 printf("Position: %ld\n", s.tell() );
40 }
41 else
42 {
43 printf("r or w, those are your choices.\n");
44 }
23 45
24 return 0; 46 return 0;
25} 47}