From 71d4e47e81c825be6c454d60083d20f8fcbff0ae Mon Sep 17 00:00:00 2001 From: Marc Slemko Date: Tue, 15 Aug 2006 22:34:04 +0000 Subject: [PATCH] Cleaned up test code for thrift exception throwing git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664758 13f79535-47bb-0310-9956-ffa450edef68 --- test/cpp/src/TestClient.cc | 42 ++++++++++++++++++++++++++++++-------- test/cpp/src/TestServer.cc | 2 +- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/test/cpp/src/TestClient.cc b/test/cpp/src/TestClient.cc index 42272d31..2e2f61bf 100644 --- a/test/cpp/src/TestClient.cc +++ b/test/cpp/src/TestClient.cc @@ -325,26 +325,52 @@ int main(int argc, char** argv) { } printf("}\n"); - /* test multi exception */ + /* test exception */ try { - Xtruct result = testClient.testMultiException("Xception", "test 1"); + printf("testClient.testException(\"Xception\") =>"); + testClient.testException("Xception"); + printf(" void\nFAILURE\n"); } catch(Xception& e) { - printf("testClient.testMulticException(\"Xception\", \"test 1\") => {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); + printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); } - + + try { + printf("testClient.testException(\"success\") =>"); + testClient.testException("success"); + printf(" void\n"); + } catch(...) { + printf(" exception\nFAILURE\n"); + } + + /* test multi exception */ + try { + printf("testClient.testMultiException(\"Xception\", \"test 1\") =>"); + Xtruct result = testClient.testMultiException("Xception", "test 1"); + printf(" result\nFAILURE\n"); + } catch(Xception& e) { + printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); + } + + try { + printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>"); Xtruct result = testClient.testMultiException("Xception2", "test 2"); + printf(" result\nFAILURE\n"); } catch(Xception2& e) { - printf("testClient.testMultiException(\"Xception2\", \"test 2\") => {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str()); + printf(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str()); } - Xtruct result = testClient.testMultiException("success", "test 3"); + try { + printf("testClient.testMultiException(\"success\", \"test 3\") =>"); + Xtruct result = testClient.testMultiException("success", "test 3"); + printf(" {{\"%s\"}}\n", result.string_thing.c_str()); + } catch(...) { + printf(" exception\nFAILURE\n"); + } - 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); diff --git a/test/cpp/src/TestServer.cc b/test/cpp/src/TestServer.cc index 4df37af1..9e5cf910 100644 --- a/test/cpp/src/TestServer.cc +++ b/test/cpp/src/TestServer.cc @@ -246,7 +246,7 @@ class TestServer : public ThriftTestServerIf { virtual struct Xtruct testMultiException(std::string arg0, std::string arg1) throw(struct Xception, struct Xception2) { - printf("testException(%s, %s)\n", arg0.c_str(), arg1.c_str()); + printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str()); if(arg0.compare("Xception") == 0) { Xception e; -- 2.17.1