| 775 | } |
| 776 | |
| 777 | static void test_jsapi_util_string_char16_data(GjsUnitTestFixture* fx, |
| 778 | const void*) { |
| 779 | char16_t* chars; |
| 780 | size_t len; |
| 781 | |
| 782 | JS::ConstUTF8CharsZ jschars(VALID_UTF8_STRING, strlen(VALID_UTF8_STRING)); |
| 783 | JS::RootedString str(fx->cx, JS_NewStringCopyUTF8Z(fx->cx, jschars)); |
| 784 | g_assert_true(gjs_string_get_char16_data(fx->cx, str, &chars, &len)); |
| 785 | std::u16string result(chars, len); |
| 786 | g_assert_true(result == u"\xc9\xd6 foobar \u30df"); |
| 787 | g_free(chars); |
| 788 | |
| 789 | // Try with a string that is likely to be stored as Latin-1 |
| 790 | str = JS_NewStringCopyZ(fx->cx, "abcd"); |
| 791 | bool ok = gjs_string_get_char16_data(fx->cx, str, &chars, &len); |
| 792 | g_assert_true(ok); |
| 793 | |
| 794 | result.assign(chars, len); |
| 795 | g_assert_true(result == u"abcd"); |
| 796 | g_free(chars); |
| 797 | } |
| 798 | |
| 799 | static void test_jsapi_util_string_to_ucs4(GjsUnitTestFixture* fx, |
| 800 | const void*) { |
nothing calls this directly
no test coverage detected