Menu

[r2149]: / framework / trunk / tests / todec_test.cpp  Maximize  Restore  History

Download this file

57 lines (54 with data), 1.3 kB

 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
#include "todec.h"
#include "test.h"
#include <iostream>
#include <sstream>
template<typename T>
void test_single()
{
using cppcms::impl::cint;
std::ostringstream a,b;
a << cint(std::numeric_limits<T>::min()) << " "
<< cint(std::numeric_limits<T>::max()) << " "
<< cint(T(1)) << " "
<< cint(T(0)) << " "
<< cint(T(-1)) << " "
<< cint(T(10)) << " "
<< cint(T(-10)) << " "
<< cint(T(12345)) << " "
<< cint(T(-12345)) << " ";
b << (std::numeric_limits<T>::min()) << " "
<< (std::numeric_limits<T>::max()) << " "
<< (T(1)) << " "
<< (T(0)) << " "
<< (T(-1)) << " "
<< (T(10)) << " "
<< (T(-10)) << " "
<< (T(12345)) << " "
<< (T(-12345)) << " ";
if(a.str()!=b.str()) {
std::cerr << "Error!!! \n " << a.str() << "\n " << b.str() << std::endl;
TEST(a.str() == b.str());
}
else {
std::cout << "Ok \n " << a.str() << "\n " << b.str() << std::endl;
}
}
int main()
{
try {
test_single<unsigned short>();
test_single<unsigned int>();
test_single<unsigned long int>();
test_single<unsigned long long int>();
test_single<short>();
test_single<int>();
test_single<long int>();
test_single<long long int>();
}
catch(std::exception const &e) {
std::cerr << e.what() << std::endl;
return 1;
}
std::cout << "Ok\n";
return 0;
}
MongoDB Logo MongoDB