mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-04 13:07:32 +00:00
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.
This commit is contained in:
1 parent
f2fbb65aaa
commit
83e0bfdfd6
1 file changed
+24
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user