aboutsummaryrefslogtreecommitdiffstats
path: root/tests/locale_test.cpp
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2014-07-30 10:53:48 -0700
committerDan Albert <danalbert@google.com>2014-07-30 17:09:46 -0700
commit1aec7c1a35b2d03038b194967d5ebdc8e2c24b80 (patch)
tree977211860df02be4f4c0843cf231ec6c3da88ee6 /tests/locale_test.cpp
parent0f7ed163cf6c1fe6d71a1d7e5fb6d0989213be85 (diff)
downloadandroid_bionic-1aec7c1a35b2d03038b194967d5ebdc8e2c24b80.tar.gz
android_bionic-1aec7c1a35b2d03038b194967d5ebdc8e2c24b80.tar.bz2
android_bionic-1aec7c1a35b2d03038b194967d5ebdc8e2c24b80.zip
Proper MB_CUR_MAX.
Previously this was hard coded to 4. This is only the case for UTF-8 locales. As a side effect, this properly reports C.UTF-8 as the default locale instead of C. Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
Diffstat (limited to 'tests/locale_test.cpp')
-rw-r--r--tests/locale_test.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/locale_test.cpp b/tests/locale_test.cpp
index 7d063f9dd..325f6ceda 100644
--- a/tests/locale_test.cpp
+++ b/tests/locale_test.cpp
@@ -48,8 +48,8 @@ TEST(locale, localeconv) {
}
TEST(locale, setlocale) {
- EXPECT_STREQ("C", setlocale(LC_ALL, NULL));
- EXPECT_STREQ("C", setlocale(LC_CTYPE, NULL));
+ EXPECT_STREQ("C.UTF-8", setlocale(LC_ALL, NULL));
+ EXPECT_STREQ("C.UTF-8", setlocale(LC_CTYPE, NULL));
errno = 0;
EXPECT_EQ(NULL, setlocale(-1, NULL));
@@ -105,3 +105,20 @@ TEST(locale, uselocale) {
EXPECT_EQ(n, uselocale(NULL));
}
+
+TEST(locale, mb_cur_max) {
+ // We can't reliably test the behavior with setlocale(3) or the behavior for
+ // initial program conditions because (unless we're the only test that was
+ // run), another test has almost certainly called uselocale(3) in this thread.
+ // See b/16685652.
+ locale_t cloc = newlocale(LC_ALL, "C", 0);
+ locale_t cloc_utf8 = newlocale(LC_ALL, "C.UTF-8", 0);
+
+ uselocale(cloc);
+ ASSERT_EQ(1U, MB_CUR_MAX);
+ uselocale(cloc_utf8);
+ ASSERT_EQ(4U, MB_CUR_MAX);
+
+ freelocale(cloc);
+ freelocale(cloc_utf8);
+}