aboutsummaryrefslogtreecommitdiff
path: root/src/unit/archive.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-06-07 07:00:09 +0000
committerMike Buland <eichlan@xagasoft.com>2008-06-07 07:00:09 +0000
commita153962ffe93e70f2419efeab904b515c99c2eda (patch)
treea41cb06283025598fcecead56daaf2cfc4a3f6fe /src/unit/archive.cpp
parent3ac57795fe8e28915523de6dd95e336a3eaa8064 (diff)
downloadlibbu++-a153962ffe93e70f2419efeab904b515c99c2eda.tar.gz
libbu++-a153962ffe93e70f2419efeab904b515c99c2eda.tar.bz2
libbu++-a153962ffe93e70f2419efeab904b515c99c2eda.tar.xz
libbu++-a153962ffe93e70f2419efeab904b515c99c2eda.zip
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.
Diffstat (limited to '')
-rw-r--r--src/unit/archive.cpp50
1 files changed, 42 insertions, 8 deletions
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:
15 { 15 {
16 setName("Archive"); 16 setName("Archive");
17 addTest( Unit::testPrimitives ); 17 addTest( Unit::testPrimitives );
18 addTest( Unit::testContainers );
18 } 19 }
19 20
20 virtual ~Unit() 21 virtual ~Unit()
@@ -42,8 +43,8 @@ public:
42 ar << (unsigned int)14; 43 ar << (unsigned int)14;
43 ar << (long)15; 44 ar << (long)15;
44 ar << (unsigned long)16; 45 ar << (unsigned long)16;
45 //ar << (long long)17; 46 ar << (long long)17;
46 //ar << (unsigned long long)18; 47 ar << (unsigned long long)18;
47 ar.close(); 48 ar.close();
48 } 49 }
49 mb.setPos( 0 ); 50 mb.setPos( 0 );
@@ -65,8 +66,8 @@ public:
65 unsigned int p14; 66 unsigned int p14;
66 long p15; 67 long p15;
67 unsigned long p16; 68 unsigned long p16;
68 //long long p17; 69 long long p17;
69 //unsigned long long p18; 70 unsigned long long p18;
70 ar >> p1; 71 ar >> p1;
71 ar >> p2; 72 ar >> p2;
72 ar >> p3; 73 ar >> p3;
@@ -83,8 +84,8 @@ public:
83 ar >> p14; 84 ar >> p14;
84 ar >> p15; 85 ar >> p15;
85 ar >> p16; 86 ar >> p16;
86 //ar >> p17; 87 ar >> p17;
87 //ar >> p18; 88 ar >> p18;
88 unitTest( p1 == 1 ); 89 unitTest( p1 == 1 );
89 unitTest( p2 == 2 ); 90 unitTest( p2 == 2 );
90 unitTest( p3 == 3 ); 91 unitTest( p3 == 3 );
@@ -101,8 +102,41 @@ public:
101 unitTest( p14 == 14 ); 102 unitTest( p14 == 14 );
102 unitTest( p15 == 15 ); 103 unitTest( p15 == 15 );
103 unitTest( p16 == 16 ); 104 unitTest( p16 == 16 );
104 //unitTest( p17 == 17 ); 105 unitTest( p17 == 17 );
105 //unitTest( p18 == 18 ); 106 unitTest( p18 == 18 );
107 ar.close();
108 }
109 }
110
111 void testContainers()
112 {
113 Bu::MemBuf mb;
114 {
115 Bu::Archive ar( mb, Bu::Archive::save );
116 Bu::FString sStr("This is a test string.");
117 Bu::List<int> lList;
118 lList.append( 10 );
119 lList.append( 20 );
120 lList.append( 30 );
121 lList.append( 40 );
122 ar << sStr;
123 ar << lList;
124 ar.close();
125 }
126 mb.setPos( 0 );
127 {
128 Bu::Archive ar( mb, Bu::Archive::load );
129 Bu::FString sStr;
130 Bu::List<int> lList;
131 ar >> sStr;
132 ar >> lList;
133 unitTest( sStr == "This is a test string." );
134 unitTest( lList.getSize() == 4 );
135 Bu::List<int>::iterator i = lList.begin();
136 unitTest( *i == 10 ); i++;
137 unitTest( *i == 20 ); i++;
138 unitTest( *i == 30 ); i++;
139 unitTest( *i == 40 );
106 ar.close(); 140 ar.close();
107 } 141 }
108 } 142 }