This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Allow quotes in tst-fmon.data, and make output easier to read


Here is a patch to make it easier to read the test data for tst-fmon.

I included a few test cases fetched from examples in the POSIX
standard.  Some of these tests currently fail.  I'm not sure if you
want to include them or not?  I believe one of the examples in the
POSIX standard are a mistake (use an alternative pos/neg style), but
haven't had time to report the problem to the Austin group.

2003-11-23  Petter Reinholdtsen  <pere@hungry.com>

	* tst-fmon.sh tst-fmon.data: Allow quotes around the result
	string, to make it easier to see important whitespace.

	* tst-fmon.data: Add test cases for the examples in the POSIX
	standard.

	* tst-fmon.sh tst-fmon.c: Clean up output, making sure both
	programs use the same capitalization and output order.

Index: localedata/tst-fmon.c
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-fmon.c,v
retrieving revision 1.7
diff -u -3 -p -u -r1.7 tst-fmon.c
--- localedata/tst-fmon.c	16 Jun 2003 07:24:46 -0000	1.7
+++ localedata/tst-fmon.c	23 Nov 2003 17:38:04 -0000
@@ -58,8 +58,8 @@ main (int argc, char *argv[])
   if (strcmp (s, argv[4]) != 0)
     {
       printf ("\
-locale: \"%s\", format: \"%s\", expected: \"%s\", got: \"%s\" => %s\n",
-	      argv[1], argv[2], argv[4], s,
+Locale: \"%s\" Format: \"%s\" Value: \"%s\" Recieved: \"%s\" Expected: \"%s\" => %s\n",
+	      argv[1], argv[2], argv[3], s, argv[4],
 	      strcmp (s, argv[4]) != 0 ? "false" : "correct");
       exit (EXIT_FAILURE);
     }
Index: localedata/tst-fmon.sh
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-fmon.sh,v
retrieving revision 1.14
diff -u -3 -p -u -r1.14 tst-fmon.sh
--- localedata/tst-fmon.sh	16 Jun 2003 07:25:07 -0000	1.14
+++ localedata/tst-fmon.sh	23 Nov 2003 17:38:05 -0000
@@ -44,16 +44,17 @@ errcode=0
 while IFS="	" read locale format value expect; do
     case "$locale" in '#'*) continue ;; esac
     if [ -n "$format" ]; then
+	expect=`echo -n "$expect" | sed 's/^\"\(.*\)\"$/\1/'`
 	if LOCPATH=${common_objpfx}localedata \
 	   GCONV_PATH=${common_objpfx}/iconvdata \
 	   ${run_program_prefix} ${common_objpfx}localedata/tst-fmon \
 	   "$locale" "$format" "$value" "$expect" ; then
 	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
-		 "Value: \"${value}\" Expect: \"${expect}\"  passed"
+		 "Value: \"${value}\" Expected: \"${expect}\"  passed"
 	else
 	    errcode=$?
 	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
-		 "Value: \"${value}\" Expect: \"${expect}\"    failed"
+		 "Value: \"${value}\" Expected: \"${expect}\"    failed"
 	fi
     fi
 done < $datafile
Index: localedata/tst-fmon.data
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-fmon.data,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 tst-fmon.data
--- localedata/tst-fmon.data	1 Mar 2002 05:20:48 -0000	1.10
+++ localedata/tst-fmon.data	23 Nov 2003 17:38:05 -0000
@@ -28,6 +28,8 @@
 # #2    format string which is fed into strfmon
 # #3    double value that is used for formatting
 # #4    the expected result (may contain trailing spaces!)
+#       This field might be enclosed with "" to make it easier to see
+#       the white space
 #
 # First the implementation without any locale-dependent data
 # - no currency symbol is printed, formatting is somewhat standard
@@ -127,6 +129,80 @@
 en_US.ISO-8859-1	%#5n	123.45		 $   123.45
 en_US.ISO-8859-1	%#5n	-123.45		-$   123.45
 en_US.ISO-8859-1	%#5n	3456.781	 $ 3,456.78
+
+#
+# Examples from the posix standard,
+# <URL:http://www.opengroup.org/onlinepubs/007904975/functions/strfmon.html>
+#
+# The currently failing tests are commented with 'bad'
+
+# Default formatting
+en_US.ISO-8859-1	%n	123.45		"$123.45"
+en_US.ISO-8859-1	%n	-123.45		"-$123.45"
+en_US.ISO-8859-1	%n	3456.78		"$3,456.78"
+
+# Right align within an 11-character field
+en_US.ISO-8859-1	%11n	123.45		"    $123.45"
+en_US.ISO-8859-1	%11n	-123.45		"   -$123.45"
+en_US.ISO-8859-1	%11n	3456.78		"  $3,456.78"
+
+# Aligned columns for values up to 99999
+en_US.ISO-8859-1	%#5n		123.45		" $   123.45"
+en_US.ISO-8859-1	%#5n		-123.45		"-$   123.45"
+en_US.ISO-8859-1	%#5n		3456.781	" $ 3,456.78"
+
+# Specify a fill character
+en_US.ISO-8859-1	%=*#5n		123.45		" $***123.45"
+en_US.ISO-8859-1	%=*#5n		-123.45		"-$***123.45"
+en_US.ISO-8859-1	%=*#5n		3456.781	" $*3,456.78"
+
+# Fill characters do not use grouping, even if the fill character is a digit
+en_US.ISO-8859-1	%=0#5n		123.45		" $000123.45"
+en_US.ISO-8859-1	%=0#5n		-123.45		"-$000123.45"
+en_US.ISO-8859-1	%=0#5n		3456.781	" $03,456.78"
+
+# Disable the grouping separator
+en_US.ISO-8859-1	%^#5n		123.45		" $  123.45"
+en_US.ISO-8859-1	%^#5n		-123.45		"-$  123.45"
+en_US.ISO-8859-1	%^#5n		3456.781	" $ 3456.78"
+
+# Round off to whole units
+en_US.ISO-8859-1	%^#5.0n		123.45		" $  123"
+en_US.ISO-8859-1	%^#5.0n		-123.45		"-$  123"
+en_US.ISO-8859-1	%^#5.0n		3456.781	" $ 3457"
+
+# Increase the precision
+en_US.ISO-8859-1	%^#5.4n		123.45		" $  123.4500"
+en_US.ISO-8859-1	%^#5.4n		-123.45		"-$  123.4500"
+en_US.ISO-8859-1	%^#5.4n		3456.781	" $ 3456.7810"
+
+# Use an alternative pos/neg style
+# bad " $   123.45" (one space too much)
+en_US.ISO-8859-1	%(#5n		123.45		"$   123.45"
+en_US.ISO-8859-1	%(#5n		-123.45		"($   123.45)"
+# bad "" $ 3,456.78"
+en_US.ISO-8859-1	%(#5n		3456.78		"$ 3,456.78"
+
+# Disable the currency symbol
+# bad "    123.45" (one space too much)
+en_US.ISO-8859-1	%!(#5n		123.45		"   123.45"
+en_US.ISO-8859-1	%!(#5n		-123.45		"(   123.45)"
+# bad "  3,456.78"
+en_US.ISO-8859-1	%!(#5n		3456.781	" 3,456.78"
+
+# Left-justify the output
+# bad " $123.4500    "
+en_US.ISO-8859-1	%-14#5.4n	123.45		" $   123.4500 "
+# bad "-$123.4500    "
+en_US.ISO-8859-1	%-14#5.4n	-123.45		"-$   123.4500 "
+# bad " $3,456.7810  "
+en_US.ISO-8859-1	%-14#5.4n	3456.781	" $ 3,456.7810 "
+
+# Corresponding right-justified output
+en_US.ISO-8859-1	%14#5.4n	123.45		"  $   123.4500"
+en_US.ISO-8859-1	%14#5.4n	-123.45		" -$   123.4500"
+en_US.ISO-8859-1	%14#5.4n	3456.781	"  $ 3,456.7810"
+
 #
 # check all cs_precedes/sign_posn/sep_by_space combinations using
 # special test locales.  The six characters after the "_" indicate


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]