From d1e486136db52b466b788c1d81a5c88b6f24acd9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 2 Nov 2006 06:14:41 +0000 Subject: Added the SBuffer class, a memory buffer that can be used like a stream. Yay! --- src/tests/sbuffer.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/tests/sbuffer.cpp (limited to 'src/tests/sbuffer.cpp') diff --git a/src/tests/sbuffer.cpp b/src/tests/sbuffer.cpp new file mode 100644 index 0000000..d8bbe4d --- /dev/null +++ b/src/tests/sbuffer.cpp @@ -0,0 +1,27 @@ +#include "sbuffer.h" + +int main() +{ + SBuffer buf; + + buf.write("abcdefg", 7 ); + + printf("tell: %d\n", buf.tell() ); + + char abuf[6]; + int nRead; + nRead = buf.read( abuf, 5 ); + abuf[nRead] = '\0'; + printf("Read %d bytes \"%s\"\n", nRead, abuf ); + + buf.setPos( 0 ); + nRead = buf.read( abuf, 5 ); + abuf[nRead] = '\0'; + printf("Read %d bytes \"%s\"\n", nRead, abuf ); + + nRead = buf.read( abuf, 5 ); + abuf[nRead] = '\0'; + printf("Read %d bytes \"%s\"\n", nRead, abuf ); + +} + -- cgit v1.2.3