summaryrefslogtreecommitdiff
path: root/src/unit/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit/archive.cpp')
-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 }