diff options
author | Dan Albert <danalbert@google.com> | 2014-08-06 21:09:52 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-06 17:14:55 +0000 |
commit | bc0d65c114f3ead6d89f8e92622bc941d731b01c (patch) | |
tree | de1ee3c2512ec5a64b2849a069e15bf7830c9e6c /tests | |
parent | 5b39a44575e01ecf65397ffb7518efc3c65a6d8b (diff) | |
parent | 6035e6cc8317600c3100fdf1070890c3e42715a7 (diff) | |
download | bionic-bc0d65c114f3ead6d89f8e92622bc941d731b01c.zip bionic-bc0d65c114f3ead6d89f8e92622bc941d731b01c.tar.gz bionic-bc0d65c114f3ead6d89f8e92622bc941d731b01c.tar.bz2 |
Merge "Proper MB_CUR_MAX." into lmp-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/locale_test.cpp | 21 | ||||
-rw-r--r-- | tests/stdio_test.cpp | 5 |
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/locale_test.cpp b/tests/locale_test.cpp index 7d063f9..325f6ce 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); +} diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 18dae9c..bb86509 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -427,6 +427,9 @@ TEST(stdio, snprintf_negative_zero_5084292) { } TEST(stdio, snprintf_utf8_15439554) { + locale_t cloc = newlocale(LC_ALL, "C.UTF-8", 0); + uselocale(cloc); + // http://b/15439554 char buf[BUFSIZ]; @@ -442,6 +445,8 @@ TEST(stdio, snprintf_utf8_15439554) { // 4-byte character. snprintf(buf, sizeof(buf), "%d\xf0\xa4\xad\xa2%d", 1, 2); EXPECT_STREQ("1𤭢2", buf); + + freelocale(cloc); } TEST(stdio, fprintf_failures_7229520) { |