diff options
author | Dan Albert <danalbert@google.com> | 2014-07-29 22:42:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-28 22:45:16 +0000 |
commit | a1a813da8184153606bfcf8ffcce557eda09a5ba (patch) | |
tree | 3eb7532024aeb353a8af568e7b3a82c055910fff /tests | |
parent | 8db0ce7050b0f6ee3874456394a1d7cb0d336c3a (diff) | |
parent | 4e5860958767ecc7bc455d2a5e1d2a2096a1c79f (diff) | |
download | bionic-a1a813da8184153606bfcf8ffcce557eda09a5ba.zip bionic-a1a813da8184153606bfcf8ffcce557eda09a5ba.tar.gz bionic-a1a813da8184153606bfcf8ffcce557eda09a5ba.tar.bz2 |
Merge "Fix mbsrtowcs(3)'s handling of len parameter." into lmp-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wchar_test.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp index a5f5f63..f052ce6 100644 --- a/tests/wchar_test.cpp +++ b/tests/wchar_test.cpp @@ -340,8 +340,19 @@ void test_mbsrtowcs(mbstate_t* ps) { ASSERT_EQ(static_cast<wchar_t>(0x00a2), out[1]); ASSERT_EQ(static_cast<wchar_t>(0x20ac), out[2]); ASSERT_EQ(static_cast<wchar_t>(0x24b62), out[3]); + // Check that valid has advanced to the next unread character. ASSERT_EQ('e', *valid); + wmemset(out, L'x', sizeof(out) / sizeof(wchar_t)); + ASSERT_EQ(2U, mbsrtowcs(out, &valid, 4, ps)); + ASSERT_EQ(L'e', out[0]); + ASSERT_EQ(L'f', out[1]); + ASSERT_EQ(L'\0', out[2]); + // Check that we didn't clobber the rest of out. + ASSERT_EQ(L'x', out[3]); + // Check that valid has advanced to the end of the string. + ASSERT_EQ(L'\0', *valid); + const char* invalid = "A" "\xc2\x20" "ef"; ASSERT_EQ(static_cast<size_t>(-1), mbsrtowcs(out, &invalid, 4, ps)); EXPECT_EQ(EILSEQ, errno); |