Add a unit test for %n.
Change-Id: I9335e089d66c98d34577f5e1d1a54b8f507b94f6
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 18fa64a..8eb65a6 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -183,6 +183,18 @@
snprintf(buf, sizeof(buf), "%zd", v);
}
+#if !defined(__GLIBC__)
+TEST(stdio, snprintf_n_format_specifier_not_implemented) {
+ char buf[32];
+ int i = 0;
+ // We deliberately don't implement %n, so it's treated like
+ // any other unrecognized format specifier.
+ EXPECT_EQ(5, snprintf(buf, sizeof(buf), "a %n b", &i));
+ EXPECT_EQ(0, i);
+ EXPECT_STREQ("a n b", buf);
+}
+#endif
+
TEST(stdio, snprintf_smoke) {
char buf[BUFSIZ];