// 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); // printf("In: %a\nOut: %a\n", dVal, pFlt->getValue() ); 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( 0.000000000000001928173 ); rw( 1.0 ); rw( 0.0 ); rw( M_PI ); } test negitave { rw( -8485738457.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 ); } }