From 74dd68ad611d15abf16a65c36a7cfd3f4492930a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 16:25:22 +0000 Subject: Made the repo less libbu++-centric. --- c++-libbu++/src/tests/clone.cpp | 22 +++++++++++++++++++ c++-libbu++/src/tests/dump.cpp | 30 ++++++++++++++++++++++++++ c++-libbu++/src/tests/int.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 c++-libbu++/src/tests/clone.cpp create mode 100644 c++-libbu++/src/tests/dump.cpp create mode 100644 c++-libbu++/src/tests/int.cpp (limited to 'c++-libbu++/src/tests') diff --git a/c++-libbu++/src/tests/clone.cpp b/c++-libbu++/src/tests/clone.cpp new file mode 100644 index 0000000..8533376 --- /dev/null +++ b/c++-libbu++/src/tests/clone.cpp @@ -0,0 +1,22 @@ +#include "gats/types.h" + +#include + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + Gats::Object *pBase = Gats::Object::strToGats("{\"Thing\": 3.14159, \"bool\": true, \"list\":[\"string\",44,{\"Stuff\":{\"list\":[],\"what?\":false}}]}"); + + sio << *pBase << sio.nl; + + Gats::Object *pNew = pBase->clone(); + delete pBase; + + sio << *pNew << sio.nl; + + delete pNew; + + return 0; +} + diff --git a/c++-libbu++/src/tests/dump.cpp b/c++-libbu++/src/tests/dump.cpp new file mode 100644 index 0000000..e0dcb52 --- /dev/null +++ b/c++-libbu++/src/tests/dump.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + File fIn( argv[1], File::Read ); + Gats::GatsStream gsIn( fIn ); + + for(;;) + { + sio << "Reading from file position: " << fIn.tell() << sio.nl; + Gats::Object *pObj = gsIn.readObject(); + if( !pObj ) + { + if( gsIn.hasReadBuffer() ) + { + sio << "Premature end of stream detected, have " + << gsIn.getReadBufferSize() << "b." << sio.nl; + } + return 0; + } + + sio << *pObj << sio.nl; + } +} + diff --git a/c++-libbu++/src/tests/int.cpp b/c++-libbu++/src/tests/int.cpp new file mode 100644 index 0000000..c19df9c --- /dev/null +++ b/c++-libbu++/src/tests/int.cpp @@ -0,0 +1,47 @@ +#include "gats/integer.h" + +#include +#include +#include + +using namespace Bu; + +void hexdump( char *dat, int iSize ) +{ + static const char *hex="0123456789ABCDEF"; + printf("----\n"); + for( int j = 0; j < iSize; j += 8 ) + { + for( int k = j; /*k < iSize &&*/ k < j+8; k++ ) + printf((k>4)&0x0F], hex[dat[k]&0x0F] ); + printf("| "); + for( int k = j; k < iSize && k < j+8; k++ ) + printf("%c ", (dat[k]>13&&dat[k]<127)?(dat[k]):('.') ); + printf("\n"); + } + printf("----\n"); +} + +int main( int argc, char *argv[] ) +{ + for( int j = 1; j < argc; j++ ) + { + int64_t i = strtoll( argv[j], NULL, 10 ); + MemBuf mb; + Gats::Integer::writePackedInt( mb, i ); + hexdump( mb.getString().getStr(), mb.getString().getSize() ); + } +/* + sio << "Before: " << i << sio.nl; + Gats::Integer::writePackedInt( mb, i ); + mb.write("aaa", 3 ); + mb.setPos( 0 ); + Gats::Integer::readPackedInt( mb, i ); + sio << "After: " << i << sio.nl; + char buf[4]; + buf[mb.read( buf, 3 )] = '\0'; + sio << "Extra: \"" << buf << "\"" << sio.nl; +*/ + return 0; +} + -- cgit v1.2.3