From 5b71560c65f6d7a8b4fd05eeabb814b379c854c3 Mon Sep 17 00:00:00 2001 From: Sokwhan Huh Date: Fri, 3 Mar 2023 21:03:40 +0000 Subject: [PATCH] Add test cases for String standard functions with Unicode in Supplemental Multilingual Plane --- tests/simple/testdata/string.textproto | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/simple/testdata/string.textproto b/tests/simple/testdata/string.textproto index 10d4142d..5458080e 100644 --- a/tests/simple/testdata/string.textproto +++ b/tests/simple/testdata/string.textproto @@ -72,6 +72,11 @@ section { expr: "'завтра'.startsWith('за')" value: { bool_value: true } } + test { + name: "unicode_smp" + expr: "'\U0001F431\U0001F600\U0001F61B'.startsWith('\U0001F431')" + value: { bool_value: true } + } } section { name: "ends_with" @@ -106,6 +111,11 @@ section { expr: "'forté'.endsWith('té')" value: { bool_value: true } } + test { + name: "unicode_smp" + expr: "'\U0001F431\U0001F600\U0001F61B'.endsWith('\U0001F61B')" + value: { bool_value: true } + } } section { name: "matches" @@ -150,6 +160,11 @@ section { expr: "'mañana'.matches('a+ñ+a+')" value: { bool_value: true } } + test { + name: "unicode_smp" + expr: "'\U0001F431\U0001F600\U0001F600'.matches('(a|\U0001F600){2}')" + value: { bool_value: true } + } } section { name: "concatentation" @@ -157,12 +172,12 @@ section { test { name: "concat_true" expr: "'he' + 'llo'" - value: { string_value: "hello"} + value: { string_value: "hello" } } test { name: "concat_with_spaces" expr: "'hello' + ' ' == 'hello'" - value: { bool_value: false} + value: { bool_value: false } } test { name: "concat_empty_string_beginning" @@ -189,6 +204,11 @@ section { expr: "'r' + 'ô' + 'le'" value: { string_value: "rôle" } } + test { + name: "ascii_unicode_unicode_smp" + expr: "'a' + 'ÿ' + '\U0001F431'" + value: { string_value: "aÿ\xf0\x9f\x90\xb1" } + } test { name: "empty_unicode" expr: "'' + 'Ω' + ''" @@ -223,6 +243,11 @@ section { expr: "'Straße'.contains('aß')" value: { bool_value: true } } + test { + name: "contains_unicode_smp" + expr: "'\U0001F431\U0001F600\U0001F601'.contains('\U0001F600')" + value: { bool_value: true } + } test { name: "empty_contains" expr: "''.contains('something')"