diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tests/buffer.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/buffer.cpp b/src/tests/buffer.cpp new file mode 100644 index 0000000..a1a1105 --- /dev/null +++ b/src/tests/buffer.cpp | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "bu/membuf.h" | ||
| 2 | #include "bu/buffer.h" | ||
| 3 | #include "bu/file.h" | ||
| 4 | |||
| 5 | using namespace Bu; | ||
| 6 | |||
| 7 | int main( int argc, char *argv[] ) | ||
| 8 | { | ||
| 9 | argc--,argv++; | ||
| 10 | if( argc == 0 ) | ||
| 11 | { | ||
| 12 | MemBuf mOut; | ||
| 13 | Buffer bOut( mOut, 10 ); | ||
| 14 | |||
| 15 | for( int j = 0; j < 4; j++ ) | ||
| 16 | bOut.write("hi ", 3 ); | ||
| 17 | |||
| 18 | printf("Preflush: \"%s\"\n", mOut.getString().getStr() ); | ||
| 19 | bOut.flush(); | ||
| 20 | |||
| 21 | printf("Final: \"%s\"\n", mOut.getString().getStr() ); | ||
| 22 | } | ||
| 23 | else | ||
| 24 | { | ||
| 25 | File fIn( *argv, File::Read ); | ||
| 26 | Buffer bIn( fIn, 10 ); | ||
| 27 | |||
| 28 | char buf[5]; | ||
| 29 | for( int j = 0; j < 5; j++ ) | ||
| 30 | { | ||
| 31 | buf[bIn.read( buf, 4 )] = '\0'; | ||
| 32 | printf("Four chars: \"%s\"\n", buf ); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | |||
