MCPcopy Create free account
hub / github.com/ElementsProject/elements / unescape_unicode_test

Function unescape_unicode_test

src/univalue/test/unitester.cpp:139–159  ·  view source on GitHub ↗

Test \u handling

Source from the content-addressed store, hash-verified

137
138// Test \u handling
139void unescape_unicode_test()
140{
141 UniValue val;
142 bool testResult;
143 // Escaped ASCII (quote)
144 testResult = val.read("[\"\\u0022\"]");
145 f_assert(testResult);
146 f_assert(val[0].get_str() == "\"");
147 // Escaped Basic Plane character, two-byte UTF-8
148 testResult = val.read("[\"\\u0191\"]");
149 f_assert(testResult);
150 f_assert(val[0].get_str() == "\xc6\x91");
151 // Escaped Basic Plane character, three-byte UTF-8
152 testResult = val.read("[\"\\u2191\"]");
153 f_assert(testResult);
154 f_assert(val[0].get_str() == "\xe2\x86\x91");
155 // Escaped Supplementary Plane character U+1d161
156 testResult = val.read("[\"\\ud834\\udd61\"]");
157 f_assert(testResult);
158 f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
159}
160
161int main (int argc, char *argv[])
162{

Callers 1

mainFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected