MCPcopy Create free account
hub / github.com/apache/thrift / main

Function main

test/cpp/src/TemplateStreamOpTest.cpp:198–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196};
197
198int main() {
199 std::cout << "Testing template_streamop with ThriftTest types..." << std::endl;
200
201 // Test 1: Test with std::ostringstream
202 {
203 Xtruct x;
204 x.__set_string_thing("test string");
205 x.__set_byte_thing(42);
206 x.__set_i32_thing(12345);
207 x.__set_i64_thing(9876543210LL);
208
209 std::ostringstream oss;
210 oss << x;
211 std::string result = oss.str();
212
213 std::cout << " Generated output: " << result << std::endl;
214
215 assert(!result.empty());
216 assert(result.find("test string") != std::string::npos);
217 assert(result.find("42") != std::string::npos);
218 assert(result.find("12345") != std::string::npos);
219 std::cout << " ✓ std::ostringstream works: " << result << std::endl;
220 }
221
222 // Test 2: Test with custom MinimalStream
223 {
224 Xtruct x;
225 x.__set_string_thing("custom stream");
226 x.__set_byte_thing(7);
227 x.__set_i32_thing(999);
228 x.__set_i64_thing(1234567890LL);
229
230 MinimalStream ms;
231 ms << x;
232 std::string result = ms.str();
233
234 assert(!result.empty());
235 assert(result.find("custom stream") != std::string::npos);
236 assert(result.find("7") != std::string::npos);
237 assert(result.find("999") != std::string::npos);
238 std::cout << " ✓ MinimalStream works: " << result << std::endl;
239 }
240
241 // Test 3: Test nested structures
242 {
243 Xtruct x;
244 x.__set_string_thing("inner");
245 x.__set_i32_thing(100);
246
247 Xtruct2 x2;
248 x2.__set_byte_thing(5);
249 x2.__set_struct_thing(x);
250 x2.__set_i32_thing(200);
251
252 std::ostringstream oss;
253 oss << x2;
254 std::string result = oss.str();
255

Callers

nothing calls this directly

Calls 8

printToFunction · 0.85
nowFunction · 0.85
strMethod · 0.80
emptyMethod · 0.80
findMethod · 0.80
clearMethod · 0.65
to_stringFunction · 0.50
countMethod · 0.45

Tested by

no test coverage detected