comparison OrthancFramework/UnitTestsSources/ToolboxTests.cpp @ 4393:e8e95b80194f

removing usage of deprecated JsonCpp classes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Dec 2020 18:55:32 +0100
parents bf7b9edf6b81
children f7104e9d044c
comparison
equal deleted inserted replaced
4392:3af1d763763a 4393:e8e95b80194f
31 #include "../Sources/IDynamicObject.h" 31 #include "../Sources/IDynamicObject.h"
32 #include "../Sources/OrthancException.h" 32 #include "../Sources/OrthancException.h"
33 #include "../Sources/Toolbox.h" 33 #include "../Sources/Toolbox.h"
34 34
35 using namespace Orthanc; 35 using namespace Orthanc;
36
37 TEST(Toolbox, Json)
38 {
39 Json::Value a = Json::objectValue;
40 a["hello"] = "world";
41
42 std::string b = "{\"hello\" : \"world\"}";
43
44 Json::Value c;
45 ASSERT_TRUE(Toolbox::ReadJson(c, b));
46
47 std::string d, e;
48 Toolbox::WriteJson(d, a, true);
49 Toolbox::WriteJson(e, c, true);
50 ASSERT_EQ(d, e);
51
52 std::string f, g;
53 Toolbox::WriteJson(f, a, false);
54 Toolbox::WriteJson(g, c, false);
55 ASSERT_EQ(f, g);
56
57 /**
58 * Check compatibility with the serialized string generated by
59 * JsonCpp 1.7.4 (Ubuntu 18.04). "StripSpaces()" removes the
60 * trailing end-of-line character that was not present in the
61 * deprecated serialization classes of JsonCpp.
62 **/
63 ASSERT_EQ(Toolbox::StripSpaces(d), "{\"hello\":\"world\"}");
64 ASSERT_EQ(Toolbox::StripSpaces(f), "{\n \"hello\" : \"world\"\n}");
65 }
36 66
37 TEST(Toolbox, Base64_allByteValues) 67 TEST(Toolbox, Base64_allByteValues)
38 { 68 {
39 std::string toEncode; 69 std::string toEncode;
40 std::string base64Result; 70 std::string base64Result;