diff options
author | Elliott Hughes <enh@google.com> | 2014-06-05 20:10:09 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-06-05 23:19:15 -0700 |
commit | 69f05d291d848de654c72e5278de8ca06fbf5d2f (patch) | |
tree | f43847693b03d7978e7234577f2d6d843f3ec356 /tests/stdio_test.cpp | |
parent | 8aabecf35c71a8255db259cba01005eea10485cf (diff) |
Fix the printf family for non-ASCII.
The bug here turned out to be that we hadn't increased the constant
corresponding to the maximum number of bytes in a character to match
our new implementation, so any character requiring more than a byte
in UTF-8 would break our printf family.
Bug: 15439554
Change-Id: I693e5e6eb11c640b5886e848502908ec5fff53b1
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r-- | tests/stdio_test.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 0ff85bf00..e291f52fe 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -426,7 +426,26 @@ TEST(stdio, snprintf_negative_zero_5084292) { EXPECT_STREQ("-0.000000", buf); } +TEST(stdio, snprintf_utf8_15439554) { + // http://b/15439554 + char buf[BUFSIZ]; + + // 1-byte character. + snprintf(buf, sizeof(buf), "%dx%d", 1, 2); + EXPECT_STREQ("1x2", buf); + // 2-byte character. + snprintf(buf, sizeof(buf), "%d\xc2\xa2%d", 1, 2); + EXPECT_STREQ("1¢2", buf); + // 3-byte character. + snprintf(buf, sizeof(buf), "%d\xe2\x82\xac%d", 1, 2); + EXPECT_STREQ("1€2", buf); + // 4-byte character. + snprintf(buf, sizeof(buf), "%d\xf0\xa4\xad\xa2%d", 1, 2); + EXPECT_STREQ("1𤭢2", buf); +} + TEST(stdio, fprintf_failures_7229520) { + // http://b/7229520 FILE* fp; // Unbuffered case where the fprintf(3) itself fails. |