summaryrefslogtreecommitdiff
path: root/tests/lib/libc/stdio
diff options
context:
space:
mode:
authorjruoho <jruoho@NetBSD.org>2011-07-08 06:38:03 +0000
committerjruoho <jruoho@NetBSD.org>2011-07-08 06:38:03 +0000
commitadc22b8f2c5868e8d074e5bf4d7b5487c3ff2b93 (patch)
tree7251f394e3eb46915230e1020efd7bc25b0b53ab /tests/lib/libc/stdio
parent4e06dd9c1cf6e9dd4e3a69e6e185a317d963fcc4 (diff)
Split out 't_printf' and 't_scanf' from 't_format' to gain the common
"functional scope" for the test files.
Diffstat (limited to 'tests/lib/libc/stdio')
-rw-r--r--tests/lib/libc/stdio/Makefile5
-rw-r--r--tests/lib/libc/stdio/t_printf.c81
-rw-r--r--tests/lib/libc/stdio/t_scanf.c (renamed from tests/lib/libc/stdio/t_format.c)60
3 files changed, 91 insertions, 55 deletions
diff --git a/tests/lib/libc/stdio/Makefile b/tests/lib/libc/stdio/Makefile
index fc6c6bfc658..8a32a60d2fa 100644
--- a/tests/lib/libc/stdio/Makefile
+++ b/tests/lib/libc/stdio/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2011/05/01 16:36:37 jruoho Exp $
+# $NetBSD: Makefile,v 1.5 2011/07/08 06:38:04 jruoho Exp $
.include <bsd.own.mk>
@@ -6,7 +6,8 @@ TESTSDIR= ${TESTSBASE}/lib/libc/stdio
TESTS_C+= t_clearerr
TESTS_C+= t_fmemopen
-TESTS_C+= t_format
TESTS_C+= t_popen
+TESTS_C+= t_printf
+TESTS_C+= t_scanf
.include <bsd.test.mk>
diff --git a/tests/lib/libc/stdio/t_printf.c b/tests/lib/libc/stdio/t_printf.c
new file mode 100644
index 00000000000..34b1263a24a
--- /dev/null
+++ b/tests/lib/libc/stdio/t_printf.c
@@ -0,0 +1,81 @@
+/* $NetBSD: t_printf.c,v 1.1 2011/07/08 06:38:04 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+ATF_TC(sprintf_dotzero);
+ATF_TC_HEAD(sprintf_dotzero, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", \
+ "PR lib/32951: %.0f formats (0.0,0.5] to \"0.\"");
+}
+
+ATF_TC_BODY(sprintf_dotzero, tc)
+{
+ char s[4];
+
+ ATF_CHECK(snprintf(s, sizeof(s), "%.0f", 0.1) == 1);
+ ATF_REQUIRE_STREQ(s, "0");
+}
+
+ATF_TC(sprintf_zeropad);
+ATF_TC_HEAD(sprintf_zeropad, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "output format zero padding");
+}
+
+ATF_TC_BODY(sprintf_zeropad, tc)
+{
+ char str[1024];
+
+ ATF_CHECK(sprintf(str, "%010f", 0.0) == 10);
+ ATF_REQUIRE_STREQ(str, "000.000000");
+
+ /* ieeefp */
+#ifndef __vax__
+ /* PR/44113: printf(3) should ignore zero padding for nan/inf */
+ ATF_CHECK(sprintf(str, "%010f", NAN) == 10);
+ ATF_REQUIRE_STREQ(str, " nan");
+ ATF_CHECK(sprintf(str, "%010f", INFINITY) == 10);
+ ATF_REQUIRE_STREQ(str, " inf");
+#endif
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, sprintf_dotzero);
+ ATF_TP_ADD_TC(tp, sprintf_zeropad);
+
+ return atf_no_error();
+}
diff --git a/tests/lib/libc/stdio/t_format.c b/tests/lib/libc/stdio/t_scanf.c
index a44f80d31cc..f1697f67e84 100644
--- a/tests/lib/libc/stdio/t_format.c
+++ b/tests/lib/libc/stdio/t_scanf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_format.c,v 1.5 2010/12/23 13:34:46 pgoyette Exp $ */
+/* $NetBSD: t_scanf.c,v 1.1 2011/07/08 06:38:04 jruoho Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,62 +31,19 @@
#include <stdio.h>
#include <string.h>
-ATF_TC(zero_padding);
-
-ATF_TC_HEAD(zero_padding, tc)
-{
-
- atf_tc_set_md_var(tc, "descr", "output format zero padding");
-}
-
-ATF_TC_BODY(zero_padding, tc)
-{
- char str[1024];
-
- ATF_CHECK(sprintf(str, "%010f", 0.0) == 10);
- ATF_REQUIRE_STREQ(str, "000.000000");
-
- /* ieeefp */
-#ifndef __vax__
- /* PR/44113: printf(3) should ignore zero padding for nan/inf */
- ATF_CHECK(sprintf(str, "%010f", NAN) == 10);
- ATF_REQUIRE_STREQ(str, " nan");
- ATF_CHECK(sprintf(str, "%010f", INFINITY) == 10);
- ATF_REQUIRE_STREQ(str, " inf");
-#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);
+#define NUM -0x1234
+#define STRNUM ___STRING(NUM)
-ATF_TC_HEAD(sscanf_neg_hex, tc)
+ATF_TC(sscanf_neghex);
+ATF_TC_HEAD(sscanf_neghex, 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)
+ATF_TC_BODY(sscanf_neghex, tc)
{
-#define NUM -0x1234
-#define STRNUM ___STRING(NUM)
-
int i;
sscanf(STRNUM, "%i", &i);
@@ -97,7 +54,6 @@ ATF_TC_BODY(sscanf_neg_hex, tc)
}
ATF_TC(sscanf_whitespace);
-
ATF_TC_HEAD(sscanf_whitespace, tc)
{
@@ -119,9 +75,7 @@ ATF_TC_BODY(sscanf_whitespace, tc)
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_neghex);
ATF_TP_ADD_TC(tp, sscanf_whitespace);
return atf_no_error();