From a153962ffe93e70f2419efeab904b515c99c2eda Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 7 Jun 2008 07:00:09 +0000 Subject: Fixed the bugs in the archive system. Both the List container and FString had inconsistancies when archiving compared to their STL counterparts, they are now compatible on every system I can imagine. Also, List now uses a long instead of an int for sizing, and the other containers should as well. I'll check on that later. That means that the files will all be larger on a 64 bit system, but such is life. The same thing happens when you use STL classes. There may be other inconsistancies down the road, we'll see. --- src/unit/archive.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'src/unit/archive.cpp') diff --git a/src/unit/archive.cpp b/src/unit/archive.cpp index 531ece1..8e71f4b 100644 --- a/src/unit/archive.cpp +++ b/src/unit/archive.cpp @@ -15,6 +15,7 @@ public: { setName("Archive"); addTest( Unit::testPrimitives ); + addTest( Unit::testContainers ); } virtual ~Unit() @@ -42,8 +43,8 @@ public: ar << (unsigned int)14; ar << (long)15; ar << (unsigned long)16; - //ar << (long long)17; - //ar << (unsigned long long)18; + ar << (long long)17; + ar << (unsigned long long)18; ar.close(); } mb.setPos( 0 ); @@ -65,8 +66,8 @@ public: unsigned int p14; long p15; unsigned long p16; - //long long p17; - //unsigned long long p18; + long long p17; + unsigned long long p18; ar >> p1; ar >> p2; ar >> p3; @@ -83,8 +84,8 @@ public: ar >> p14; ar >> p15; ar >> p16; - //ar >> p17; - //ar >> p18; + ar >> p17; + ar >> p18; unitTest( p1 == 1 ); unitTest( p2 == 2 ); unitTest( p3 == 3 ); @@ -101,8 +102,41 @@ public: unitTest( p14 == 14 ); unitTest( p15 == 15 ); unitTest( p16 == 16 ); - //unitTest( p17 == 17 ); - //unitTest( p18 == 18 ); + unitTest( p17 == 17 ); + unitTest( p18 == 18 ); + ar.close(); + } + } + + void testContainers() + { + Bu::MemBuf mb; + { + Bu::Archive ar( mb, Bu::Archive::save ); + Bu::FString sStr("This is a test string."); + Bu::List lList; + lList.append( 10 ); + lList.append( 20 ); + lList.append( 30 ); + lList.append( 40 ); + ar << sStr; + ar << lList; + ar.close(); + } + mb.setPos( 0 ); + { + Bu::Archive ar( mb, Bu::Archive::load ); + Bu::FString sStr; + Bu::List lList; + ar >> sStr; + ar >> lList; + unitTest( sStr == "This is a test string." ); + unitTest( lList.getSize() == 4 ); + Bu::List::iterator i = lList.begin(); + unitTest( *i == 10 ); i++; + unitTest( *i == 20 ); i++; + unitTest( *i == 30 ); i++; + unitTest( *i == 40 ); ar.close(); } } -- cgit v1.2.3