From 4a8f46ca0b449654626e7a68861d2fabb3fb9f48 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Fri, 7 Mar 2008 20:12:07 +0000 Subject: [PATCH] Add more complete base64 testing for C++ JSON protocol. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665559 13f79535-47bb-0310-9956-ffa450edef68 --- test/DebugProtoTest.thrift | 10 ++++++++++ test/JSONProtoTest.cpp | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift index 7f031c66..fb86bf4c 100644 --- a/test/DebugProtoTest.thrift +++ b/test/DebugProtoTest.thrift @@ -65,6 +65,16 @@ struct RandomStuff { 8: double triple, } +struct Base64 { + 1: i32 a, + 2: binary b1, + 3: binary b2, + 4: binary b3, + 5: binary b4, + 6: binary b5, + 7: binary b6, +} + service Srv { i32 Janky(i32 arg) } diff --git a/test/JSONProtoTest.cpp b/test/JSONProtoTest.cpp index 077d2c46..30d712f9 100644 --- a/test/JSONProtoTest.cpp +++ b/test/JSONProtoTest.cpp @@ -104,6 +104,10 @@ int main() { assert(hm == hm2); + hm2.big[0].a_bite = 0xFF; + + assert(hm != hm2); + Doubles dub; dub.nan = HUGE_VAL/HUGE_VAL; dub.inf = HUGE_VAL; @@ -115,5 +119,22 @@ int main() { dub.negzero = -0.0; cout << facebook::thrift::ThriftJSONString(dub) << endl << endl; + cout << "Testing base" << endl; + + Base64 base; + base.a = 123; + base.b1 = "1"; + base.b2 = "12"; + base.b3 = "123"; + base.b4 = "1234"; + base.b5 = "12345"; + base.b6 = "123456"; + + base.write(proto.get()); + Base64 base2; + base2.read(proto.get()); + + assert(base == base2); + return 0; } -- 2.17.1