From 555ba77568b6faf18ebaed06cd08615deab2d8e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 7 Jun 2008 05:30:58 +0000 Subject: This is a testing version. Nothing should be broken, but I won't gurantee it. I wouldn't update to this just yet, if you have problems, back off a rev. I'm trying to update the code to work on both 32bit, and 64bit systems, and hopefully anything else that comes along. Currently some of the archive code is broken, testing must be done on both archetectures. --- src/unit/archive.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/unit/archive.cpp (limited to 'src/unit') diff --git a/src/unit/archive.cpp b/src/unit/archive.cpp new file mode 100644 index 0000000..61e3567 --- /dev/null +++ b/src/unit/archive.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2007-2008 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 "bu/unitsuite.h" +#include "bu/membuf.h" + +class Unit : public Bu::UnitSuite +{ +public: + Unit() + { + setName("Archive"); + addTest( Unit::testPrimitives ); + } + + virtual ~Unit() + { + } + + void testPrimitives() + { + Bu::MemBuf mb; + { + Bu::Archive ar( mb, Bu::Archive::save ); + ar << (int8_t)1; + ar << (uint8_t)2; + ar << (int16_t)3; + ar << (uint16_t)4; + ar << (int32_t)5; + ar << (uint32_t)6; + ar << (int64_t)7; + ar << (uint64_t)8; + ar << (char)9; + ar << (unsigned char)10; + ar << (short)11; + ar << (unsigned short)12; + ar << (int)13; + ar << (unsigned int)14; + ar << (long)15; + ar << (unsigned long)16; + //ar << (long long)17; + //ar << (unsigned long long)18; + ar.close(); + } + mb.setPos( 0 ); + { + Bu::Archive ar( mb, Bu::Archive::load ); + int8_t p1; + uint8_t p2; + int16_t p3; + uint16_t p4; + int32_t p5; + uint32_t p6; + int64_t p7; + uint64_t p8; + signed char p9; + unsigned char p10; + short p11; + unsigned short p12; + int p13; + unsigned int p14; + long p15; + unsigned long p16; + //long long p17; + //unsigned long long p18; + ar >> p1; + ar >> p2; + ar >> p3; + ar >> p4; + ar >> p5; + ar >> p6; + ar >> p7; + ar >> p8; + ar >> p9; + ar >> p10; + ar >> p11; + ar >> p12; + ar >> p13; + ar >> p14; + ar >> p15; + ar >> p16; + //ar >> p17; + //ar >> p18; + unitTest( p1 == 1 ); + unitTest( p2 == 2 ); + unitTest( p3 == 3 ); + unitTest( p4 == 4 ); + unitTest( p5 == 5 ); + unitTest( p6 == 6 ); + unitTest( p7 == 7 ); + unitTest( p8 == 8 ); + unitTest( p9 == 9 ); + unitTest( p10 == 10 ); + unitTest( p11 == 11 ); + unitTest( p12 == 12 ); + unitTest( p13 == 13 ); + unitTest( p14 == 14 ); + unitTest( p15 == 15 ); + unitTest( p16 == 16 ); + //unitTest( p17 == 17 ); + //unitTest( p18 == 18 ); + ar.close(); + } + } +}; + +int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); } -- cgit v1.2.3