summaryrefslogtreecommitdiff
path: root/tests/tsprintf.c
diff options
context:
space:
mode:
authorthevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4>2009-01-19 13:51:45 +0000
committerthevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4>2009-01-19 13:51:45 +0000
commit0069fdaba22ab14c6bdc0c930f89f6e780df327c (patch)
treed4785f773b945522d5b1e79ac738d1c56abd4b76 /tests/tsprintf.c
parentbddb8d55f325e400f81636867b3f38a8e22aee34 (diff)
downloadmpfr-0069fdaba22ab14c6bdc0c930f89f6e780df327c.tar.gz
tests/tsprintf.c: check if native types are really processed by libc printf.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5837 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsprintf.c')
-rw-r--r--tests/tsprintf.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/tsprintf.c b/tests/tsprintf.c
index 7a1df36a6..99d03985d 100644
--- a/tests/tsprintf.c
+++ b/tests/tsprintf.c
@@ -139,6 +139,55 @@ check_vsprintf (const char *expected, const char *fmt, ...)
return n0;
}
+
+static void
+native_types ()
+{
+ char c = 'a';
+ int i = -1;
+ unsigned int ui = 1;
+ double d = -1.25;
+ char s[] = "test";
+
+ char buf[255];
+
+ sprintf (buf, "%a", d);
+ check_vsprintf (buf, "%a", d);
+
+ sprintf (buf, "%c", c);
+ check_vsprintf (buf, "%c", c);
+
+ sprintf (buf, "%d", i);
+ check_vsprintf (buf, "%d", i);
+
+ sprintf (buf, "%e", d);
+ check_vsprintf (buf, "%e", d);
+
+ sprintf (buf, "%f", d);
+ check_vsprintf (buf, "%f", d);
+
+ sprintf (buf, "%i", i);
+ check_vsprintf (buf, "%i", i);
+
+ sprintf (buf, "%g", d);
+ check_vsprintf (buf, "%g", d);
+
+ sprintf (buf, "%o", i);
+ check_vsprintf (buf, "%o", i);
+
+ sprintf (buf, "%s", s);
+ check_vsprintf (buf, "%s", s);
+
+ sprintf (buf, "%u", ui);
+ check_vsprintf (buf, "%u", ui);
+
+ sprintf (buf, "%x", ui);
+ check_vsprintf (buf, "%x", ui);
+
+ sprintf (buf, "%p", &i);
+ check_vsprintf (buf, "%p", &i);
+}
+
static int
decimal (void)
{
@@ -780,6 +829,7 @@ main (int argc, char **argv)
locale = setlocale (LC_ALL, "C");
#endif
+ native_types ();
hexadecimal ();
binary ();
decimal ();