aboutsummaryrefslogtreecommitdiff
path: root/src/unit/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unit/archive.cpp111
1 files changed, 111 insertions, 0 deletions
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 @@
1/*
2 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/unitsuite.h"
9#include "bu/membuf.h"
10
11class Unit : public Bu::UnitSuite
12{
13public:
14 Unit()
15 {
16 setName("Archive");
17 addTest( Unit::testPrimitives );
18 }
19
20 virtual ~Unit()
21 {
22 }
23
24 void testPrimitives()
25 {
26 Bu::MemBuf mb;
27 {
28 Bu::Archive ar( mb, Bu::Archive::save );
29 ar << (int8_t)1;
30 ar << (uint8_t)2;
31 ar << (int16_t)3;
32 ar << (uint16_t)4;
33 ar << (int32_t)5;
34 ar << (uint32_t)6;
35 ar << (int64_t)7;
36 ar << (uint64_t)8;
37 ar << (char)9;
38 ar << (unsigned char)10;
39 ar << (short)11;
40 ar << (unsigned short)12;
41 ar << (int)13;
42 ar << (unsigned int)14;
43 ar << (long)15;
44 ar << (unsigned long)16;
45 //ar << (long long)17;
46 //ar << (unsigned long long)18;
47 ar.close();
48 }
49 mb.setPos( 0 );
50 {
51 Bu::Archive ar( mb, Bu::Archive::load );
52 int8_t p1;
53 uint8_t p2;
54 int16_t p3;
55 uint16_t p4;
56 int32_t p5;
57 uint32_t p6;
58 int64_t p7;
59 uint64_t p8;
60 signed char p9;
61 unsigned char p10;
62 short p11;
63 unsigned short p12;
64 int p13;
65 unsigned int p14;
66 long p15;
67 unsigned long p16;
68 //long long p17;
69 //unsigned long long p18;
70 ar >> p1;
71 ar >> p2;
72 ar >> p3;
73 ar >> p4;
74 ar >> p5;
75 ar >> p6;
76 ar >> p7;
77 ar >> p8;
78 ar >> p9;
79 ar >> p10;
80 ar >> p11;
81 ar >> p12;
82 ar >> p13;
83 ar >> p14;
84 ar >> p15;
85 ar >> p16;
86 //ar >> p17;
87 //ar >> p18;
88 unitTest( p1 == 1 );
89 unitTest( p2 == 2 );
90 unitTest( p3 == 3 );
91 unitTest( p4 == 4 );
92 unitTest( p5 == 5 );
93 unitTest( p6 == 6 );
94 unitTest( p7 == 7 );
95 unitTest( p8 == 8 );
96 unitTest( p9 == 9 );
97 unitTest( p10 == 10 );
98 unitTest( p11 == 11 );
99 unitTest( p12 == 12 );
100 unitTest( p13 == 13 );
101 unitTest( p14 == 14 );
102 unitTest( p15 == 15 );
103 unitTest( p16 == 16 );
104 //unitTest( p17 == 17 );
105 //unitTest( p18 == 18 );
106 ar.close();
107 }
108 }
109};
110
111int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); }