Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/stdio Migrate a few more tests from old regre...
details: https://anonhg.NetBSD.org/src/rev/aca1e7fdff24
branches: trunk
changeset: 759942:aca1e7fdff24
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Dec 21 14:23:42 2010 +0000
description:
Migrate a few more tests from old regress style to atf
diffstat:
tests/lib/libc/stdio/t_format.c | 63 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diffs (77 lines):
diff -r 4565e5c47a04 -r aca1e7fdff24 tests/lib/libc/stdio/t_format.c
--- a/tests/lib/libc/stdio/t_format.c Tue Dec 21 08:53:25 2010 +0000
+++ b/tests/lib/libc/stdio/t_format.c Tue Dec 21 14:23:42 2010 +0000
@@ -56,10 +56,73 @@
#endif
}
+ATF_TC(dot_zero_f);
+
+ATF_TC_HEAD(dot_zero_f, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", \
+ "PR lib/32951: %.0f formats (0.0,0.5] to \"0.\"");
+}
+
+ATF_TC_BODY(dot_zero_f, tc)
+{
+ char s[4];
+
+ ATF_CHECK(snprintf(s, sizeof(s), "%.0f", 0.1) == 1);
+ ATF_REQUIRE_STREQ(s, "0");
+}
+
+ATF_TC(sscanf_neg_hex);
+
+ATF_TC_HEAD(sscanf_neg_hex, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", \
+ "PR lib/21691: %i and %x fail with negative hex numbers");
+}
+
+ATF_TC_BODY(sscanf_neg_hex, tc)
+{
+#define NUM -0x1234
+#define STRNUM ___STRING(NUM)
+
+ int i;
+
+ sscanf(STRNUM, "%i", &i);
+ ATF_REQUIRE(i == NUM);
+
+ sscanf(STRNUM, "%x", &i);
+ ATF_REQUIRE(i == NUM);
+}
+
+ATF_TC(sscanf_whitespace);
+
+ATF_TC_HEAD(sscanf_whitespace, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "verify sscanf skips all whitespace");
+}
+
+ATF_TC_BODY(sscanf_whitespace, tc)
+{
+ const char str[] = "\f\n\r\t\v%z";
+ char c;
+
+ /* set of "white space" symbols from isspace(3) */
+ c = 0;
+ (void)sscanf(str, "%%%c", &c);
+ ATF_REQUIRE(c == 'z');
+}
+
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, zero_padding);
+ ATF_TP_ADD_TC(tp, dot_zero_f);
+ ATF_TP_ADD_TC(tp, sscanf_neg_hex);
+ ATF_TP_ADD_TC(tp, sscanf_whitespace);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index