Add testcase for PR/44113: printf(3) should ignore zero padding for
nan/inf.
This commit is contained in:
parent
ad5cf5ab43
commit
c8fe673676
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue