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. --- src/unit/basic.unit | 191 ---------------------------------------------------- src/unit/float.unit | 84 ----------------------- src/unit/io.unit | 128 ----------------------------------- 3 files changed, 403 deletions(-) delete mode 100644 src/unit/basic.unit delete mode 100644 src/unit/float.unit delete mode 100644 src/unit/io.unit (limited to 'src/unit') diff --git a/src/unit/basic.unit b/src/unit/basic.unit deleted file mode 100644 index 2c2c31a..0000000 --- a/src/unit/basic.unit +++ /dev/null @@ -1,191 +0,0 @@ -// vim: syntax=cpp -/* - * Copyright (C) 2007-2010 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "gats/dictionary.h" -#include "gats/integer.h" -#include "gats/float.h" -#include "gats/list.h" -#include "gats/boolean.h" -#include "gats/string.h" -#include "gats/null.h" -#include "gats/gatsstream.h" - -#include "bu/membuf.h" -#include "bu/list.h" -#include "bu/sio.h" - -#include -#include - -using namespace Bu; - -suite Basic -{ - test integer - { - Bu::List lInts; - Bu::MemBuf mb; - - int64_t i = 1; - for( int x = 0; x < 256; x++ ) - { - lInts.append( i ); - Gats::Integer( i ).write( mb ); - i = -(i<<1)-i; - } - - mb.setPos( 0 ); - - for( Bu::List::iterator j = lInts.begin(); j; j++ ) - { - Gats::Object *pObj = Gats::Object::read( mb ); - if( pObj->getType() != Gats::typeInteger ) - unitFailed("Bad type read."); - - if( dynamic_cast(pObj)->getValue() != *j ) - unitFailed("Bad number."); - } - } - - test string - { - Bu::List lStrs; - Bu::MemBuf mb; - - lStrs.append( Bu::String() ); - Gats::String("").write( mb ); - - { - int iMax = 0; - for( int j = 1; j <= (1<<16); j=j<<1 ) - iMax += j; - setStepCount( iMax ); - } - for( int j = 1; j <= (1<<16); j=j<<1 ) - { - Bu::String s( j ); - for( int x = 0; x < j; x++ ) - { - s[x] = (unsigned char)(random()%256); - } - incProgress( j ); - Gats::String( s ).write( mb ); - lStrs.append( s ); - } - - mb.setPos( 0 ); - - for( Bu::List::iterator i = lStrs.begin(); i; i++ ) - { - Gats::Object *pObj = Gats::Object::read( mb ); - if( pObj->getType() != Gats::typeString ) - unitFailed("Bad type read."); - - if( *dynamic_cast(pObj) != *i ) - unitFailed("Bad string."); - } - } - - test boolean - { - Bu::List lBs; - Bu::MemBuf mb; - - for( int j = 0; j < 1024; j++ ) - { - if( random()%2 == 0 ) - { - lBs.append( true ); - Gats::Boolean( true ).write( mb ); - } - else - { - lBs.append( false ); - Gats::Boolean( false ).write( mb ); - } - } - - mb.setPos( 0 ); - - for( Bu::List::iterator i = lBs.begin(); i; i++ ) - { - Gats::Object *pObj = Gats::Object::read( mb ); - if( pObj->getType() != Gats::typeBoolean ) - unitFailed("Bad type read."); - - if( dynamic_cast(pObj)->getValue() != *i ) - unitFailed("Bad string."); - } - } - - test floats - { - Bu::MemBuf mb; - - Gats::Float( M_PI ).write( mb ); - - mb.setPos( 0 ); - - Gats::Object *pObj = Gats::Object::read( mb ); - unitTest( pObj != NULL ); - unitTest( pObj->getType() == Gats::typeFloat ); - Gats::Float *pFlt = dynamic_cast(pObj); - // sio << "old = " << M_PI << ", new = " << pFlt->getValue() << sio.nl; - unitTest( pFlt->getValue() == M_PI ); - - delete pObj; - } - - test dictionary - { - MemBuf mb; - - { - Gats::Dictionary dict; - dict.insert("bool", new Gats::Boolean(true) ); - dict.insert("int", 33403055 ); - dict.insert("str", "Hey there" ); - dict.write( mb ); - } - - mb.setPos( 0 ); - - { - Gats::Object *pRead = Gats::Object::read( mb ); - unitTest( pRead != NULL ); - Gats::Dictionary *pDict = dynamic_cast(pRead); - unitTest( pDict != NULL ); - - unitTest( pDict->getBool("bool") == true ); - unitTest( pDict->getInt("int") == 33403055 ); - unitTest( pDict->getStr("str") == "Hey there" ); - unitTest( pDict->getSize() == 3 ); - - delete pDict; - } - } - - test null - { - MemBuf mb; - { - Gats::Null n; - Gats::GatsStream gs( mb ); - gs.writeObject( &n ); - } - - mb.setPos( 0 ); - - { - Gats::GatsStream gs( mb ); - Gats::Object *pObj = gs.readObject(); - unitTest( pObj->getType() == Gats::typeNull ); - delete pObj; - } - } -} diff --git a/src/unit/float.unit b/src/unit/float.unit deleted file mode 100644 index b1eb063..0000000 --- a/src/unit/float.unit +++ /dev/null @@ -1,84 +0,0 @@ -// vim: syntax=cpp -/* - * Copyright (C) 2007-2010 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "gats/dictionary.h" -#include "gats/float.h" -#include "gats/string.h" - -#include "bu/membuf.h" -#include "bu/list.h" -#include "bu/sio.h" - -#include -#include - -using namespace Bu; - -suite Basic -{ - void rw( double dVal ) - { - Bu::MemBuf mb; - - Gats::Float( dVal ).write( mb ); - - mb.setPos( 0 ); - - Gats::Object *pObj = Gats::Object::read( mb ); - unitTest( pObj != NULL ); - unitTest( pObj->getType() == Gats::typeFloat ); - Gats::Float *pFlt = dynamic_cast(pObj); - Bu::String sHex; - for( Bu::String::iterator i = mb.getString().begin(); i; i++ ) - { - sHex += "0123456789abcdef"[(((uint8_t)*i)>>4)&0x0f]; - sHex += "0123456789abcdef"[(*i)&0x0f]; - sHex += ' '; - } - printf("In: %a\nOut: %a\nRaw: %s\n", dVal, pFlt->getValue(), sHex.getStr() ); - if( isnan( dVal ) ) - unitTest( isnan(pFlt->getValue()) == isnan(dVal) ); - else - unitTest( pFlt->getValue() == dVal ); - unitTest( signbit(pFlt->getValue()) == signbit(dVal) ); - - delete pObj; - } - - test positive - { - rw( 8485738457.0 ); - rw( 63723.0 ); - rw( 0.000000000000001928173 ); - rw( 1.0 ); - rw( 0.0 ); - rw( M_PI ); - } - - test negitave - { - rw( -8485738457.0 ); - rw( -63723.0 ); - rw( -0.000000000000001928173 ); - rw( -1.0 ); - rw( -0.0 ); - rw( -M_PI ); - } - - test inf - { - rw( INFINITY ); - rw( -INFINITY ); - } - - test nan - { - rw( NAN ); - rw( -NAN ); - } -} diff --git a/src/unit/io.unit b/src/unit/io.unit deleted file mode 100644 index 1a9747f..0000000 --- a/src/unit/io.unit +++ /dev/null @@ -1,128 +0,0 @@ -// vim: syntax=cpp -/* - * Copyright (C) 2007-2010 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "gats/dictionary.h" -#include "gats/integer.h" -#include "gats/float.h" -#include "gats/list.h" -#include "gats/boolean.h" -#include "gats/string.h" -#include "gats/gatsstream.h" - -#include "bu/membuf.h" -#include "bu/list.h" -#include "bu/sio.h" - -#include - -using namespace Bu; - -suite Basic -{ - test basic - { - Bu::String sTmpFileName("temp-XXXXXXXXX"); - Bu::File fIo = tempFile( sTmpFileName ); - - { - Gats::Dictionary dTest; - dTest.insert("age", 27 ); - dTest.insert("firstName", "Mike"); - dTest.insert("lastName", "Buland"); - dTest.insert("awake", true ); - - Gats::GatsStream sGats( fIo ); - sGats.writeObject( &dTest ); - } - - fIo.setPos( 0 ); - - { - Gats::GatsStream sGats( fIo ); - Gats::Object *pObj = sGats.readObject(); - unitTest( pObj != NULL ); - unitTest( pObj->getType() == Gats::typeDictionary ); - Gats::Dictionary *pDic = dynamic_cast(pObj); - unitTest( pDic->getSize() == 4 ); - unitTest( pDic->getInt("age") == 27 ); - unitTest( pDic->getStr("firstName") == "Mike" ); - unitTest( pDic->getStr("lastName") == "Buland" ); - unitTest( pDic->getBool("awake") == true ); - - delete pDic; - } - } - - test spacers - { - Bu::String sTmpFileName("temp-XXXXXXXXX"); - Bu::File fIo = tempFile( sTmpFileName ); - - { - Gats::GatsStream sGats( fIo ); - Gats::Integer i( -157 ); - sGats.writeObject( &i ); - fIo.write( "\x00\x00\x00", 3 ); - Gats::String s("negative one hundred and fifty seven"); - sGats.writeObject( &s ); - } - - fIo.setPos( 0 ); - - { - Gats::GatsStream sGats( fIo ); - Gats::Object *pObj1 = sGats.readObject(); - unitTest( pObj1 != NULL ); - unitTest( pObj1->getType() == Gats::typeInteger ); - unitTest( dynamic_cast(pObj1)->getValue() == -157 ); - - Gats::Object *pObj2 = sGats.readObject(); - unitTest( pObj2 != NULL ); - unitTest( pObj2->getType() == Gats::typeString ); - unitTest( *dynamic_cast(pObj2) == - "negative one hundred and fifty seven" ); - - delete pObj1; - delete pObj2; - } - } - - test biggerSpacers - { - Bu::String sTmpFileName("temp-XXXXXXXXX"); - Bu::File fIo = tempFile( sTmpFileName ); - - { - Gats::GatsStream sGats( fIo ); - Gats::Integer i( -157 ); - sGats.writeObject( &i ); - fIo.write( "\x00\x00\x00\x00\x00\x00\x00\x00\x00", 9 ); - Gats::String s("negative one hundred and fifty seven"); - sGats.writeObject( &s ); - } - - fIo.setPos( 0 ); - - { - Gats::GatsStream sGats( fIo ); - Gats::Object *pObj1 = sGats.readObject(); - unitTest( pObj1 != NULL ); - unitTest( pObj1->getType() == Gats::typeInteger ); - unitTest( dynamic_cast(pObj1)->getValue() == -157 ); - - Gats::Object *pObj2 = sGats.readObject(); - unitTest( pObj2 != NULL ); - unitTest( pObj2->getType() == Gats::typeString ); - unitTest( *dynamic_cast(pObj2) == - "negative one hundred and fifty seven" ); - - delete pObj1; - delete pObj2; - } - } -} -- cgit v1.2.3