r1407@opsdev009 (orig r74442): dreiss | 2007-12-14 15:46:47 -0800
[amiethrift.git] / test / DebugProtoTest.cpp
blobbae2a16221dc8fd72f30c6c946d48387f68d08c3
1 /*
2 thrift -cpp DebugProtoTest.thrift
3 g++ -Wall -g -I../lib/cpp/src -I/usr/local/include/boost-1_33_1 \
4 DebugProtoTest.cpp gen-cpp/DebugProtoTest_types.cpp \
5 ../lib/cpp/.libs/libthrift.a -o DebugProtoTest
6 ./DebugProtoTest
7 */
9 #include <iostream>
10 #include <cmath>
11 #include "gen-cpp/DebugProtoTest_types.h"
12 #include "../lib/cpp/src/protocol/TDebugProtocol.h"
14 int main() {
15 using std::cout;
16 using std::endl;
17 using namespace thrift::test;
20 OneOfEach ooe;
21 ooe.im_true = true;
22 ooe.im_false = false;
23 ooe.a_bite = 0xd6;
24 ooe.integer16 = 27000;
25 ooe.integer32 = 1<<24;
26 ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
27 ooe.double_precision = M_PI;
28 ooe.some_characters = "Debug THIS!";
29 ooe.zomg_unicode = "\xd7\n\a\t";
31 cout << facebook::thrift::ThriftDebugString(ooe) << endl << endl;
34 Nesting n;
35 n.my_ooe = ooe;
36 n.my_ooe.integer16 = 16;
37 n.my_ooe.integer32 = 32;
38 n.my_ooe.integer64 = 64;
39 n.my_ooe.double_precision = (std::sqrt(5)+1)/2;
40 n.my_ooe.some_characters = ":R (me going \"rrrr\")";
41 n.my_ooe.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
42 "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
43 "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
44 n.my_bonk.type = 31337;
45 n.my_bonk.message = "I am a bonk... xor!";
47 cout << facebook::thrift::ThriftDebugString(n) << endl << endl;
50 HolyMoley hm;
52 hm.big.push_back(ooe);
53 hm.big.push_back(n.my_ooe);
54 hm.big[0].a_bite = 0x22;
55 hm.big[1].a_bite = 0x33;
57 std::vector<std::string> stage1;
58 stage1.push_back("and a one");
59 stage1.push_back("and a two");
60 hm.contain.insert(stage1);
61 stage1.clear();
62 stage1.push_back("then a one, two");
63 stage1.push_back("three!");
64 stage1.push_back("FOUR!!");
65 hm.contain.insert(stage1);
66 stage1.clear();
67 hm.contain.insert(stage1);
69 std::vector<Bonk> stage2;
70 hm.bonks["nothing"] = stage2;
71 stage2.resize(stage2.size()+1);
72 stage2.back().type = 1;
73 stage2.back().message = "Wait.";
74 stage2.resize(stage2.size()+1);
75 stage2.back().type = 2;
76 stage2.back().message = "What?";
77 hm.bonks["something"] = stage2;
78 stage2.clear();
79 stage2.resize(stage2.size()+1);
80 stage2.back().type = 3;
81 stage2.back().message = "quoth";
82 stage2.resize(stage2.size()+1);
83 stage2.back().type = 4;
84 stage2.back().message = "the raven";
85 stage2.resize(stage2.size()+1);
86 stage2.back().type = 5;
87 stage2.back().message = "nevermore";
88 hm.bonks["poe"] = stage2;
90 cout << facebook::thrift::ThriftDebugString(hm) << endl << endl;
93 return 0;