From 83e0bfdfd66a657f89ecfcdbf20c92f862951dda Mon Sep 17 00:00:00 2001 From: MarcZX10 <67475268+MarcZX10@users.noreply.github.com> Date: Thu, 29 Oct 2026 04:25:08 +0000 Subject: [PATCH] test(libSceSystemService): cover parsing a locale in either form Checks that BCP-47 and POSIX spellings of the same locale give the same language, script and region, that the @latin modifier supplies a script, and that C, POSIX, empty and malformed texts are refused without writing the tag. --- .../tests/SystemServiceLanguageLocale.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/libs/tests/SystemServiceLanguageLocale.cpp b/core/libs/tests/SystemServiceLanguageLocale.cpp index 95e1c8743d..c9e59d2e2a 100644 --- a/core/libs/tests/SystemServiceLanguageLocale.cpp +++ b/core/libs/tests/SystemServiceLanguageLocale.cpp @@ -84,9 +84,33 @@ void RequirePosixNormalisation() { } } +void RequireEitherForm() { + constexpr ParsedTag locales[] = { + {"en_US.UTF-8", "en", "", "US"}, + {"en-US", "en", "", "US"}, + {"zh_Hant_TW.UTF-8", "zh", "Hant", "TW"}, + {"zh-Hans-CN", "zh", "Hans", "CN"}, + {"sr_RS@latin", "sr", "Latn", "RS"}, + {"pt_BR.utf8", "pt", "", "BR"}, + {"es_419", "es", "", "419"}, + {"fr", "fr", "", ""}, + }; + for (const auto& expected : locales) { + SystemServiceLocale::Tag tag; + Require(SystemServiceLocale::ParseLocale(expected.text, tag), expected.text); + Require(tag.language == expected.language && tag.script == expected.script && tag.region == expected.region, expected.text); + } + for (std::string_view none : {"", "C", "POSIX", "C.UTF-8", "@latin", "garbage!", "english", "e", "en__US", "_US", "123"}) { + SystemServiceLocale::Tag tag{"keep", "keep", "keep"}; + Require(!SystemServiceLocale::ParseLocale(none, tag), none); + Require(tag.language == "keep" && tag.script == "keep" && tag.region == "keep", none); + } +} + } int main() { RequireBcp47Parsing(); RequirePosixNormalisation(); + RequireEitherForm(); }