From: Ulrich Drepper Date: Thu, 20 Aug 1998 17:25:24 +0000 (+0000) Subject: Add test case for snprintf. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a400eea476c3a88e2bee8bc7b2ae6d45567f3349;p=thirdparty%2Fglibc.git Add test case for snprintf. --- diff --git a/stdio-common/tst-printf.c b/stdio-common/tst-printf.c index 87578d397ae..a9a023f7ce9 100644 --- a/stdio-common/tst-printf.c +++ b/stdio-common/tst-printf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 95, 96, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -132,6 +132,7 @@ main (int argc, char *argv[]) static char shortstr[] = "Hi, Z."; static char longstr[] = "Good morning, Doctor Chandra. This is Hal. \ I am ready for my first lesson today."; + int result = 0; fmtchk("%.4x"); fmtchk("%04x"); @@ -231,18 +232,25 @@ I am ready for my first lesson today."; printf("%.17f\n",(1.0/x/10.0+1.0)*x-x); } + { + char buf[10]; + int ret = snprintf (buf, 1, "%d", 123); + printf ("snprintf (buf, 1, \"%%d\", 123) = %d\n", ret); + if (ret != -1) + abort (); + } + puts ("--- Should be no further output. ---"); rfg1 (); rfg2 (); { char buf[200]; - int result; sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three"); - result = strcmp (buf, - "onetwo three "); + result |= strcmp (buf, + "onetwo three "); puts (result != 0 ? "Test failed!" : "Test ok."); return result != 0;