-
Notifications
You must be signed in to change notification settings - Fork 0
/
SerializerTest.cpp
124 lines (105 loc) · 1.89 KB
/
SerializerTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* GPL v3
*/
#include "StdAfx.h"
#include "SerializerTest.h"
#include "Serializer.h"
SerializerTest::SerializerTest(void)
{
}
SerializerTest::~SerializerTest(void)
{
}
int SerializerTest::testInteger(){
Serializer aa;
int pp=45544;
aa<<pp;
int returne;
aa>>returne;
if (pp!=returne)
{
std::cout <<"Error testInteger: << "<<pp<<" != >>"<<returne<<std::endl;
return 1;
}
else
{
std::cout <<"Ok testInteger "<<std::endl;
return 0;
}
}
int SerializerTest::testLong(){
Serializer aa;
long pp=(unsigned long)455445455l;
aa<<pp;
long returne;
aa>>returne;
if (pp!=returne)
{
std::cout <<"Error testLong: << "<<pp<<" != >>"<<returne<<std::endl;
return 1;
}
else
{
std::cout <<"Ok testLong "<<std::endl;
return 0;
}
}
int SerializerTest::testDouble(){
Serializer aa;
double pp=45.4515454545115454;
aa<<pp;
double returne;
aa>>returne;
if (pp!=returne)
{
std::cout.precision(15);
std::cout <<"Error testDouble: << "<<pp<<" != >>"<<returne<<std::endl;
return 1;
}
else
{
std::cout <<"Ok testDouble "<<std::endl;
return 0;
}
}
int SerializerTest::testString(){
Serializer aa;
std::string ee="Un test pokkklke3334éezazeza";
aa<<ee;
std::string returne;
aa>>returne;
if (ee!=returne)
{
std::cout <<"Error testString: << "<<ee<<" != >>"<<returne<<std::endl;
return 1;
}
else
{
std::cout <<"Ok testString "<<std::endl;
return 0;
}
}
int SerializerTest::testMixStringLongInt(){
Serializer aa;
long a1=(unsigned long)499465645l;
std::string a2="Un test pokkklke3334éezazeza";
int a3=(unsigned int)60654;
aa<<a1;
aa<<a3;
aa<<a2;
long r1;
std::string r2;
int r3;
aa>>r1;
aa>>r3;
aa>>r2;
if (a1!=r1&&a2!=r2&&a3!=r3)
{
std::cout <<"Error testMixStringLongInt: << "<<a1<<":"<<a2<<":"<<a3<<" != >>"<<r1<<":"<<r2<<":"<<r3<<std::endl;
return 1;
}
else
{
std::cout <<"Ok testMixStringLongInt "<<std::endl;
return 0;
}
}