aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/epee_utils.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-30 19:16:11 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-08-16 17:06:03 +0000
commiteeca5ca0c8d7275069d45adf40546ea83edf46cc (patch)
tree71024c1a6dc4747e83f29bd4e1eeeb80094a19bd /tests/unit_tests/epee_utils.cpp
parentMerge pull request #5756 (diff)
downloadmonero-eeca5ca0c8d7275069d45adf40546ea83edf46cc.tar.xz
epee: support unicode in parsed strings
Diffstat (limited to 'tests/unit_tests/epee_utils.cpp')
-rw-r--r--tests/unit_tests/epee_utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index 946731826..c5f9a42d0 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -946,3 +946,20 @@ TEST(parsing, number)
epee::misc_utils::parse::match_number(i, s.end(), val);
ASSERT_EQ(val, "+9.34e+03");
}
+
+TEST(parsing, unicode)
+{
+ std::string bs;
+ std::string s;
+ std::string::const_iterator si;
+
+ s = "\"\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "");
+ s = "\"\\u0000\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, std::string(1, '\0'));
+ s = "\"\\u0020\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, " ");
+ s = "\"\\u1\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u12\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u123\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u1234\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "ሴ");
+ s = "\"foo\\u1234bar\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "fooሴbar");
+ s = "\"\\u3042\\u307e\\u3084\\u304b\\u3059\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "あまやかす");
+}