Modified C++ code-gen to create default constructors for all non-string primitives so that auto variable instances of structs aren't populated with
garbage. This matters because, given thrift's loosey-goosey argument and result lists, structs may only be sparsely filled.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664757 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/cpp/src/TestClient.cc b/test/cpp/src/TestClient.cc
index e977442..42272d3 100644
--- a/test/cpp/src/TestClient.cc
+++ b/test/cpp/src/TestClient.cc
@@ -13,6 +13,7 @@
using namespace facebook::thrift;
using namespace facebook::thrift::protocol;
using namespace facebook::thrift::transport;
+using namespace thrift::test;
//extern uint32_t g_socket_syscalls;
@@ -96,8 +97,8 @@
* I64 TEST
*/
printf("testI64(-34359738368)");
- int64_t i64 = testClient.testI64(-34359738368);
- printf(" = %ld\n", i64);
+ int64_t i64 = testClient.testI64(-34359738368LL);
+ printf(" = %lld\n", i64);
/**
* STRUCT TEST
@@ -109,7 +110,7 @@
out.i32_thing = -3;
out.i64_thing = -5;
Xtruct in = testClient.testStruct(out);
- printf(" = {\"%s\", %d, %d, %ld}\n",
+ printf(" = {\"%s\", %d, %d, %lld}\n",
in.string_thing.c_str(),
(int)in.byte_thing,
in.i32_thing,
@@ -125,7 +126,7 @@
out2.i32_thing = 5;
Xtruct2 in2 = testClient.testNest(out2);
in = in2.struct_thing;
- printf(" = {%d, {\"%s\", %d, %d, %ld}, %d}\n",
+ printf(" = {%d, {\"%s\", %d, %d, %lld}, %d}\n",
in2.byte_thing,
in.string_thing.c_str(),
(int)in.byte_thing,
@@ -256,8 +257,8 @@
* TYPEDEF TEST
*/
printf("testTypedef(309858235082523)");
- UserId uid = testClient.testTypedef(309858235082523);
- printf(" = %ld\n", uid);
+ UserId uid = testClient.testTypedef(309858235082523LL);
+ printf(" = %lld\n", uid);
/**
* NESTED MAP TEST
@@ -292,7 +293,7 @@
printf(" = {");
map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
- printf("%ld => {", i_iter->first);
+ printf("%lld => {", i_iter->first);
map<Numberz,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
@@ -302,7 +303,7 @@
map<Numberz, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
- printf("%d => %ld, ", um->first, um->second);
+ printf("%d => %lld, ", um->first, um->second);
}
printf("}, ");
@@ -310,7 +311,7 @@
list<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
- printf("{\"%s\", %d, %d, %ld}, ",
+ printf("{\"%s\", %d, %d, %lld}, ",
x->string_thing.c_str(),
(int)x->byte_thing,
x->i32_thing,
@@ -324,9 +325,29 @@
}
printf("}\n");
- uint64_t stop = now();
- printf("Total time: %lu us\n", stop-start);
+ /* test multi exception */
+ try {
+ Xtruct result = testClient.testMultiException("Xception", "test 1");
+
+ } catch(Xception& e) {
+ printf("testClient.testMulticException(\"Xception\", \"test 1\") => {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
+ }
+
+ try {
+ Xtruct result = testClient.testMultiException("Xception2", "test 2");
+
+ } catch(Xception2& e) {
+ printf("testClient.testMultiException(\"Xception2\", \"test 2\") => {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
+ }
+
+ Xtruct result = testClient.testMultiException("success", "test 3");
+
+ printf("testClient.testMultiException(\"success\", \"test 3\") => {{\"%s\"}}\n", result.string_thing.c_str());
+
+ uint64_t stop = now();
+ printf("Total time: %llu us\n", stop-start);
+
bufferedSocket->close();
}