diff options
author | Elliott Hughes <enh@google.com> | 2018-09-05 18:47:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-05 18:47:44 +0000 |
commit | 74934aaf10d629de477095f0b92c467849f89638 (patch) | |
tree | d1256648a11d0e70828cc6dad6654160bf593557 /tests/stdio_test.cpp | |
parent | 6c7c06712e453d617336972a2e2919e9ef001dc8 (diff) | |
parent | 654cd8331b3dafb2027a3062104c6e9934af1935 (diff) |
Merge "Add the %m GNU extension to printf/wprintf."
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r-- | tests/stdio_test.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index d96da024b..4107a7490 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -2356,6 +2356,32 @@ TEST(STDIO_TEST, sprintf_30445072) { ASSERT_EQ(buf, "hello"); } +TEST(STDIO_TEST, printf_m) { + char buf[BUFSIZ]; + errno = 0; + snprintf(buf, sizeof(buf), "<%m>"); + ASSERT_STREQ("<Success>", buf); + errno = -1; + snprintf(buf, sizeof(buf), "<%m>"); + ASSERT_STREQ("<Unknown error -1>", buf); + errno = EINVAL; + snprintf(buf, sizeof(buf), "<%m>"); + ASSERT_STREQ("<Invalid argument>", buf); +} + +TEST(STDIO_TEST, wprintf_m) { + wchar_t buf[BUFSIZ]; + errno = 0; + swprintf(buf, sizeof(buf), L"<%m>"); + ASSERT_EQ(std::wstring(L"<Success>"), buf); + errno = -1; + swprintf(buf, sizeof(buf), L"<%m>"); + ASSERT_EQ(std::wstring(L"<Unknown error -1>"), buf); + errno = EINVAL; + swprintf(buf, sizeof(buf), L"<%m>"); + ASSERT_EQ(std::wstring(L"<Invalid argument>"), buf); +} + TEST(STDIO_TEST, fopen_append_mode_and_ftell) { TemporaryFile tf; SetFileTo(tf.filename, "0123456789"); |