Mercurial > hg > orthanc
comparison UnitTestsSources/UnitTestsMain.cpp @ 2071:27fd34970c52
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 14:21:29 +0200 |
parents | 35ccba7adae9 |
children | dd609a99d39a |
comparison
equal
deleted
inserted
replaced
2070:7e6afa0beaf6 | 2071:27fd34970c52 |
---|---|
943 Toolbox::UriEncode(s, "\x54\x65\x73\x74\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b\xe0\xb9\x9b\xef\xbe\x88\xc4\xb0"); | 943 Toolbox::UriEncode(s, "\x54\x65\x73\x74\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b\xe0\xb9\x9b\xef\xbe\x88\xc4\xb0"); |
944 ASSERT_EQ("Test%C3%A9%C3%A4%C3%B6%C3%B2%D0%94%CE%98%C4%9D%D7%93%D8%B5%C4%B7%D1%9B%E0%B9%9B%EF%BE%88%C4%B0", s); | 944 ASSERT_EQ("Test%C3%A9%C3%A4%C3%B6%C3%B2%D0%94%CE%98%C4%9D%D7%93%D8%B5%C4%B7%D1%9B%E0%B9%9B%EF%BE%88%C4%B0", s); |
945 } | 945 } |
946 | 946 |
947 | 947 |
948 TEST(Toolbox, AccessJson) | |
949 { | |
950 Json::Value v = Json::arrayValue; | |
951 ASSERT_EQ("nope", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
952 | |
953 v = Json::objectValue; | |
954 ASSERT_EQ("nope", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
955 ASSERT_EQ(-10, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
956 ASSERT_EQ(10, Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10)); | |
957 ASSERT_TRUE(Toolbox::GetJsonBooleanField(v, "hello", true)); | |
958 | |
959 v["hello"] = "world"; | |
960 ASSERT_EQ("world", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
961 ASSERT_THROW(Toolbox::GetJsonIntegerField(v, "hello", -10), OrthancException); | |
962 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
963 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
964 | |
965 v["hello"] = -42; | |
966 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
967 ASSERT_EQ(-42, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
968 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
969 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
970 | |
971 v["hello"] = 42; | |
972 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
973 ASSERT_EQ(42, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
974 ASSERT_EQ(42, Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10)); | |
975 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
976 | |
977 v["hello"] = false; | |
978 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
979 ASSERT_THROW(Toolbox::GetJsonIntegerField(v, "hello", -10), OrthancException); | |
980 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
981 ASSERT_FALSE(Toolbox::GetJsonBooleanField(v, "hello", true)); | |
982 } | |
983 | |
984 | |
948 int main(int argc, char **argv) | 985 int main(int argc, char **argv) |
949 { | 986 { |
950 Logging::Initialize(); | 987 Logging::Initialize(); |
951 Logging::EnableInfoLevel(true); | 988 Logging::EnableInfoLevel(true); |
952 Toolbox::DetectEndianness(); | 989 Toolbox::DetectEndianness(); |