Module Name:    src
Committed By:   njoly
Date:           Fri Nov 19 18:18:54 UTC 2010

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/lib/libc/stdio: Makefile
Added Files:
        src/tests/lib/libc/stdio: t_format.c

Log Message:
Add testcase for PR/44113: printf(3) should ignore zero padding for
nan/inf.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/t_format.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.157 src/distrib/sets/lists/tests/mi:1.158
--- src/distrib/sets/lists/tests/mi:1.157	Fri Nov 19 12:37:48 2010
+++ src/distrib/sets/lists/tests/mi	Fri Nov 19 18:18:54 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.157 2010/11/19 12:37:48 pooka Exp $
+# $NetBSD: mi,v 1.158 2010/11/19 18:18:54 njoly Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -321,6 +321,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/hash/t_sha2.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/stdio				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/stdio/t_fmemopen.debug	tests-lib-debug		debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/stdio/t_format.debug	tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_environment.debug	tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_environment_pth.debug	tests-lib-debug		debug,atf
@@ -1515,6 +1516,7 @@
 ./usr/tests/lib/libc/stdio			tests-lib-tests
 ./usr/tests/lib/libc/stdio/Atffile		tests-lib-tests		atf
 ./usr/tests/lib/libc/stdio/t_fmemopen		tests-lib-tests		atf
+./usr/tests/lib/libc/stdio/t_format		tests-lib-tests		atf
 ./usr/tests/lib/libc/string			tests-obsolete		obsolete
 ./usr/tests/lib/libc/string/Atffile		tests-obsolete		obsolete
 ./usr/tests/lib/libc/string/t_popcount		tests-obsolete		obsolete

Index: src/tests/lib/libc/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.1 src/tests/lib/libc/stdio/Makefile:1.2
--- src/tests/lib/libc/stdio/Makefile:1.1	Fri Sep 24 09:21:53 2010
+++ src/tests/lib/libc/stdio/Makefile	Fri Nov 19 18:18:53 2010
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.1 2010/09/24 09:21:53 tnozaki Exp $
+# $NetBSD: Makefile,v 1.2 2010/11/19 18:18:53 njoly Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=	${TESTSBASE}/lib/libc/stdio
 
 TESTS_C+=	t_fmemopen
+TESTS_C+=	t_format
 
 .include <bsd.test.mk>

Added files:

Index: src/tests/lib/libc/stdio/t_format.c
diff -u /dev/null src/tests/lib/libc/stdio/t_format.c:1.1
--- /dev/null	Fri Nov 19 18:18:54 2010
+++ src/tests/lib/libc/stdio/t_format.c	Fri Nov 19 18:18:53 2010
@@ -0,0 +1,62 @@
+/* $NetBSD */
+
+/*-
+ * 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(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");
+
+	/* 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");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, zero_padding);
+
+	return atf_no_error();
+}

Reply via email to