blob: d736d9573cc16d9bfbbfb94dc150b10b247ba8d0 [file] [log] [blame]
David Reiss00dcccf2007-07-21 01:18:10 +00001#include <iostream>
2#include <cmath>
3#include "gen-cpp/DebugProtoTest_types.h"
4#include "../lib/cpp/src/protocol/TDebugProtocol.h"
5
6int main() {
7 using std::cout;
8 using std::endl;
9 using namespace thrift::test;
10
11
12 OneOfEach ooe;
13 ooe.im_true = true;
14 ooe.im_false = false;
15 ooe.a_bite = 0xd6;
16 ooe.integer16 = 27000;
17 ooe.integer32 = 1<<24;
David Reiss6f226552007-08-06 20:33:00 +000018 ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
David Reiss00dcccf2007-07-21 01:18:10 +000019 ooe.double_precision = M_PI;
20 ooe.some_characters = "Debug THIS!";
21 ooe.zomg_unicode = "\xd7\n\a\t";
22
23 cout << facebook::thrift::ThriftDebugString(ooe) << endl << endl;
24
25
26 Nesting n;
27 n.my_ooe = ooe;
28 n.my_ooe.integer16 = 16;
29 n.my_ooe.integer32 = 32;
30 n.my_ooe.integer64 = 64;
31 n.my_ooe.double_precision = (std::sqrt(5)+1)/2;
32 n.my_ooe.some_characters = ":R (me going \"rrrr\")";
David Reiss8dae9942007-08-06 20:32:59 +000033 n.my_ooe.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
34 "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
35 "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
David Reiss00dcccf2007-07-21 01:18:10 +000036 n.my_bonk.type = 31337;
37 n.my_bonk.message = "I am a bonk... xor!";
38
39 cout << facebook::thrift::ThriftDebugString(n) << endl << endl;
40
41
42 HolyMoley hm;
43
44 hm.big.push_back(ooe);
45 hm.big.push_back(n.my_ooe);
46 hm.big[0].a_bite = 0x22;
47 hm.big[1].a_bite = 0x33;
48
49 std::vector<std::string> stage1;
50 stage1.push_back("and a one");
51 stage1.push_back("and a two");
52 hm.contain.insert(stage1);
53 stage1.clear();
54 stage1.push_back("then a one, two");
55 stage1.push_back("three!");
56 stage1.push_back("FOUR!!");
57 hm.contain.insert(stage1);
58 stage1.clear();
59 hm.contain.insert(stage1);
60
61 std::vector<Bonk> stage2;
62 hm.bonks["nothing"] = stage2;
63 stage2.resize(stage2.size()+1);
64 stage2.back().type = 1;
65 stage2.back().message = "Wait.";
66 stage2.resize(stage2.size()+1);
67 stage2.back().type = 2;
68 stage2.back().message = "What?";
69 hm.bonks["something"] = stage2;
70 stage2.clear();
71 stage2.resize(stage2.size()+1);
72 stage2.back().type = 3;
73 stage2.back().message = "quoth";
74 stage2.resize(stage2.size()+1);
75 stage2.back().type = 4;
76 stage2.back().message = "the raven";
77 stage2.resize(stage2.size()+1);
78 stage2.back().type = 5;
79 stage2.back().message = "nevermore";
80 hm.bonks["poe"] = stage2;
81
82 cout << facebook::thrift::ThriftDebugString(hm) << endl << endl;
83
84
85 return 0;
86}