blob: 98c66b8b7946d10d42694fd2e85cd603c2683d18 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Jake Farrell5d02b802014-01-07 21:42:01 -050020#define _USE_MATH_DEFINES
David Reiss00dcccf2007-07-21 01:18:10 +000021#include <iostream>
22#include <cmath>
23#include "gen-cpp/DebugProtoTest_types.h"
Roger Meier49ff8b12012-04-13 09:12:31 +000024#include <thrift/protocol/TDebugProtocol.h>
David Reiss00dcccf2007-07-21 01:18:10 +000025
26int main() {
27 using std::cout;
28 using std::endl;
David Reiss2a4bfd62008-04-07 23:45:00 +000029 using namespace thrift::test::debug;
David Reiss00dcccf2007-07-21 01:18:10 +000030
David Reiss00dcccf2007-07-21 01:18:10 +000031 OneOfEach ooe;
Konrad Grochowski16a23a62014-11-13 15:33:38 +010032 ooe.im_true = true;
33 ooe.im_false = false;
34 ooe.a_bite = 0x7f;
David Reiss00dcccf2007-07-21 01:18:10 +000035 ooe.integer16 = 27000;
Konrad Grochowski16a23a62014-11-13 15:33:38 +010036 ooe.integer32 = 1 << 24;
David Reiss6f226552007-08-06 20:33:00 +000037 ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
David Reiss00dcccf2007-07-21 01:18:10 +000038 ooe.double_precision = M_PI;
Konrad Grochowski16a23a62014-11-13 15:33:38 +010039 ooe.some_characters = "Debug THIS!";
40 ooe.zomg_unicode = "\xd7\n\a\t";
David Reiss00dcccf2007-07-21 01:18:10 +000041
T Jake Lucianib5e62212009-01-31 22:36:20 +000042 cout << apache::thrift::ThriftDebugString(ooe) << endl << endl;
David Reiss00dcccf2007-07-21 01:18:10 +000043
David Reiss00dcccf2007-07-21 01:18:10 +000044 Nesting n;
45 n.my_ooe = ooe;
46 n.my_ooe.integer16 = 16;
47 n.my_ooe.integer32 = 32;
48 n.my_ooe.integer64 = 64;
Konrad Grochowski16a23a62014-11-13 15:33:38 +010049 n.my_ooe.double_precision = (std::sqrt(5.0) + 1) / 2;
50 n.my_ooe.some_characters = ":R (me going \"rrrr\")";
David Reiss8dae9942007-08-06 20:32:59 +000051 n.my_ooe.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
52 "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
53 "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
Konrad Grochowski16a23a62014-11-13 15:33:38 +010054 n.my_bonk.type = 31337;
David Reiss00dcccf2007-07-21 01:18:10 +000055 n.my_bonk.message = "I am a bonk... xor!";
56
T Jake Lucianib5e62212009-01-31 22:36:20 +000057 cout << apache::thrift::ThriftDebugString(n) << endl << endl;
David Reiss00dcccf2007-07-21 01:18:10 +000058
David Reiss00dcccf2007-07-21 01:18:10 +000059 HolyMoley hm;
60
61 hm.big.push_back(ooe);
62 hm.big.push_back(n.my_ooe);
63 hm.big[0].a_bite = 0x22;
64 hm.big[1].a_bite = 0x33;
65
66 std::vector<std::string> stage1;
67 stage1.push_back("and a one");
68 stage1.push_back("and a two");
69 hm.contain.insert(stage1);
70 stage1.clear();
71 stage1.push_back("then a one, two");
72 stage1.push_back("three!");
73 stage1.push_back("FOUR!!");
74 hm.contain.insert(stage1);
75 stage1.clear();
76 hm.contain.insert(stage1);
77
78 std::vector<Bonk> stage2;
79 hm.bonks["nothing"] = stage2;
Konrad Grochowski16a23a62014-11-13 15:33:38 +010080 stage2.resize(stage2.size() + 1);
David Reiss00dcccf2007-07-21 01:18:10 +000081 stage2.back().type = 1;
82 stage2.back().message = "Wait.";
Konrad Grochowski16a23a62014-11-13 15:33:38 +010083 stage2.resize(stage2.size() + 1);
David Reiss00dcccf2007-07-21 01:18:10 +000084 stage2.back().type = 2;
85 stage2.back().message = "What?";
86 hm.bonks["something"] = stage2;
87 stage2.clear();
Konrad Grochowski16a23a62014-11-13 15:33:38 +010088 stage2.resize(stage2.size() + 1);
David Reiss00dcccf2007-07-21 01:18:10 +000089 stage2.back().type = 3;
90 stage2.back().message = "quoth";
Konrad Grochowski16a23a62014-11-13 15:33:38 +010091 stage2.resize(stage2.size() + 1);
David Reiss00dcccf2007-07-21 01:18:10 +000092 stage2.back().type = 4;
93 stage2.back().message = "the raven";
Konrad Grochowski16a23a62014-11-13 15:33:38 +010094 stage2.resize(stage2.size() + 1);
David Reiss00dcccf2007-07-21 01:18:10 +000095 stage2.back().type = 5;
96 stage2.back().message = "nevermore";
97 hm.bonks["poe"] = stage2;
98
T Jake Lucianib5e62212009-01-31 22:36:20 +000099 cout << apache::thrift::ThriftDebugString(hm) << endl << endl;
David Reiss00dcccf2007-07-21 01:18:10 +0000100
David Reiss00dcccf2007-07-21 01:18:10 +0000101 return 0;
102}