David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 20 | #include <iostream> |
| 21 | #include <cmath> |
| 22 | #include "gen-cpp/DebugProtoTest_types.h" |
| 23 | #include "../lib/cpp/src/protocol/TDebugProtocol.h" |
| 24 | |
| 25 | int main() { |
| 26 | using std::cout; |
| 27 | using std::endl; |
David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 28 | using namespace thrift::test::debug; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | OneOfEach ooe; |
| 32 | ooe.im_true = true; |
| 33 | ooe.im_false = false; |
| 34 | ooe.a_bite = 0xd6; |
| 35 | ooe.integer16 = 27000; |
| 36 | ooe.integer32 = 1<<24; |
David Reiss | 6f22655 | 2007-08-06 20:33:00 +0000 | [diff] [blame] | 37 | ooe.integer64 = (uint64_t)6000 * 1000 * 1000; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 38 | ooe.double_precision = M_PI; |
| 39 | ooe.some_characters = "Debug THIS!"; |
| 40 | ooe.zomg_unicode = "\xd7\n\a\t"; |
| 41 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 42 | cout << apache::thrift::ThriftDebugString(ooe) << endl << endl; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | Nesting n; |
| 46 | n.my_ooe = ooe; |
| 47 | n.my_ooe.integer16 = 16; |
| 48 | n.my_ooe.integer32 = 32; |
| 49 | n.my_ooe.integer64 = 64; |
| 50 | n.my_ooe.double_precision = (std::sqrt(5)+1)/2; |
| 51 | n.my_ooe.some_characters = ":R (me going \"rrrr\")"; |
David Reiss | 8dae994 | 2007-08-06 20:32:59 +0000 | [diff] [blame] | 52 | n.my_ooe.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20" |
| 53 | "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e" |
| 54 | "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc"; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 55 | n.my_bonk.type = 31337; |
| 56 | n.my_bonk.message = "I am a bonk... xor!"; |
| 57 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 58 | cout << apache::thrift::ThriftDebugString(n) << endl << endl; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 59 | |
| 60 | |
| 61 | HolyMoley hm; |
| 62 | |
| 63 | hm.big.push_back(ooe); |
| 64 | hm.big.push_back(n.my_ooe); |
| 65 | hm.big[0].a_bite = 0x22; |
| 66 | hm.big[1].a_bite = 0x33; |
| 67 | |
| 68 | std::vector<std::string> stage1; |
| 69 | stage1.push_back("and a one"); |
| 70 | stage1.push_back("and a two"); |
| 71 | hm.contain.insert(stage1); |
| 72 | stage1.clear(); |
| 73 | stage1.push_back("then a one, two"); |
| 74 | stage1.push_back("three!"); |
| 75 | stage1.push_back("FOUR!!"); |
| 76 | hm.contain.insert(stage1); |
| 77 | stage1.clear(); |
| 78 | hm.contain.insert(stage1); |
| 79 | |
| 80 | std::vector<Bonk> stage2; |
| 81 | hm.bonks["nothing"] = stage2; |
| 82 | stage2.resize(stage2.size()+1); |
| 83 | stage2.back().type = 1; |
| 84 | stage2.back().message = "Wait."; |
| 85 | stage2.resize(stage2.size()+1); |
| 86 | stage2.back().type = 2; |
| 87 | stage2.back().message = "What?"; |
| 88 | hm.bonks["something"] = stage2; |
| 89 | stage2.clear(); |
| 90 | stage2.resize(stage2.size()+1); |
| 91 | stage2.back().type = 3; |
| 92 | stage2.back().message = "quoth"; |
| 93 | stage2.resize(stage2.size()+1); |
| 94 | stage2.back().type = 4; |
| 95 | stage2.back().message = "the raven"; |
| 96 | stage2.resize(stage2.size()+1); |
| 97 | stage2.back().type = 5; |
| 98 | stage2.back().message = "nevermore"; |
| 99 | hm.bonks["poe"] = stage2; |
| 100 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 101 | cout << apache::thrift::ThriftDebugString(hm) << endl << endl; |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | return 0; |
| 105 | } |