Commit 323ce8bf authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[test] Move cctest/test-api-icu to unittests/

... api/api-icu-unittest.

Bug: v8:12781
Change-Id: Ibfc420e9d5ff0fce67f710b89a214332c7be65cc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3748164Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#81883}
parent fec831de
......@@ -167,7 +167,6 @@ v8_source_set("cctest_sources") {
"test-accessors.cc",
"test-allocation.cc",
"test-api-array-buffer.cc",
"test-api-icu.cc",
"test-api-interceptors.cc",
"test-api-stack-traces.cc",
"test-api-typed-array.cc",
......
......@@ -224,6 +224,7 @@ v8_source_set("unittests_sources") {
"../../testing/gtest-support.h",
"api/access-check-unittest.cc",
"api/accessor-unittest.cc",
"api/api-icu-unittest.cc",
"api/deserialize-unittest.cc",
"api/exception-unittest.cc",
"api/interceptor-unittest.cc",
......
......@@ -8,45 +8,44 @@
#include "include/v8-isolate.h"
#include "include/v8-local-handle.h"
#include "test/cctest/cctest.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "unicode/locid.h"
namespace {
void CheckLocaleSpecificValues(const char* locale, const char* date,
const char* number) {
CHECK(v8_str(locale)->StrictEquals(
CompileRun("Intl.NumberFormat().resolvedOptions().locale")));
CHECK(v8_str(date)->StrictEquals(
CompileRun("new Date('02/14/2020 13:45').toLocaleString()")));
CHECK(v8_str(number)->StrictEquals(
CompileRun("Number(10000.3).toLocaleString()")));
}
void SetIcuLocale(const char* locale_name) {
UErrorCode error_code = U_ZERO_ERROR;
icu::Locale locale(locale_name);
icu::Locale::setDefault(locale, error_code);
CHECK(U_SUCCESS(error_code));
}
} // namespace
TEST(LocaleConfigurationChangeNotification) {
class ApiIcuTest : public v8::TestWithContext {
public:
void CheckLocaleSpecificValues(const char* locale, const char* date,
const char* number) {
CHECK(NewString(locale)->StrictEquals(
RunJS("Intl.NumberFormat().resolvedOptions().locale")));
CHECK(NewString(date)->StrictEquals(
RunJS("new Date('02/14/2020 13:45').toLocaleString()")));
CHECK(NewString(number)->StrictEquals(
RunJS("Number(10000.3).toLocaleString()")));
}
void SetIcuLocale(const char* locale_name) {
UErrorCode error_code = U_ZERO_ERROR;
icu::Locale locale(locale_name);
icu::Locale::setDefault(locale, error_code);
CHECK(U_SUCCESS(error_code));
}
};
TEST_F(ApiIcuTest, LocaleConfigurationChangeNotification) {
icu::Locale default_locale = icu::Locale::getDefault();
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
SetIcuLocale("en_US");
isolate->LocaleConfigurationChangeNotification();
isolate()->LocaleConfigurationChangeNotification();
CheckLocaleSpecificValues("en-US", "2/14/2020, 1:45:00 PM", "10,000.3");
SetIcuLocale("ru_RU");
isolate->LocaleConfigurationChangeNotification();
isolate()->LocaleConfigurationChangeNotification();
CheckLocaleSpecificValues("ru-RU", "14.02.2020, 13:45:00", "10 000,3");
SetIcuLocale("zh_CN");
isolate->LocaleConfigurationChangeNotification();
isolate()->LocaleConfigurationChangeNotification();
CheckLocaleSpecificValues("zh-CN", "2020/2/14 13:45:00", "10,000.3");
UErrorCode error_code = U_ZERO_ERROR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment