blob: fc857b6857321351adfa045ffd18070b118dc5c7 [file] [log] [blame]
David Reiss00dcccf2007-07-21 01:18:10 +00001/*
2thrift -cpp DebugProtoTest.thrift
3g++ -Wall -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*/
8
9#include <iostream>
10#include <cmath>
11#include "gen-cpp/DebugProtoTest_types.h"
12#include "../lib/cpp/src/protocol/TDebugProtocol.h"
13
14int main() {
15 using std::cout;
16 using std::endl;
17 using namespace thrift::test;
18
19
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 = 6000000000;
27 ooe.double_precision = M_PI;
28 ooe.some_characters = "Debug THIS!";
29 ooe.zomg_unicode = "\xd7\n\a\t";
30
31 cout << facebook::thrift::ThriftDebugString(ooe) << endl << endl;
32
33
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 = "IDN Homograph Attack";
42 n.my_bonk.type = 31337;
43 n.my_bonk.message = "I am a bonk... xor!";
44
45 cout << facebook::thrift::ThriftDebugString(n) << endl << endl;
46
47
48 HolyMoley hm;
49
50 hm.big.push_back(ooe);
51 hm.big.push_back(n.my_ooe);
52 hm.big[0].a_bite = 0x22;
53 hm.big[1].a_bite = 0x33;
54
55 std::vector<std::string> stage1;
56 stage1.push_back("and a one");
57 stage1.push_back("and a two");
58 hm.contain.insert(stage1);
59 stage1.clear();
60 stage1.push_back("then a one, two");
61 stage1.push_back("three!");
62 stage1.push_back("FOUR!!");
63 hm.contain.insert(stage1);
64 stage1.clear();
65 hm.contain.insert(stage1);
66
67 std::vector<Bonk> stage2;
68 hm.bonks["nothing"] = stage2;
69 stage2.resize(stage2.size()+1);
70 stage2.back().type = 1;
71 stage2.back().message = "Wait.";
72 stage2.resize(stage2.size()+1);
73 stage2.back().type = 2;
74 stage2.back().message = "What?";
75 hm.bonks["something"] = stage2;
76 stage2.clear();
77 stage2.resize(stage2.size()+1);
78 stage2.back().type = 3;
79 stage2.back().message = "quoth";
80 stage2.resize(stage2.size()+1);
81 stage2.back().type = 4;
82 stage2.back().message = "the raven";
83 stage2.resize(stage2.size()+1);
84 stage2.back().type = 5;
85 stage2.back().message = "nevermore";
86 hm.bonks["poe"] = stage2;
87
88 cout << facebook::thrift::ThriftDebugString(hm) << endl << endl;
89
90
91 return 0;
92}