Back to index

glibc  2.9
dat_strfmon.c
Go to the documentation of this file.
00001 /*
00002  *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
00003  *
00004  *      FILE: dat_strfmon.c
00005  *
00006  *      STRFMON:  size_t strfmon (char *buf, size_t nbyte, char *fmt, ... );
00007  */
00008 
00009 /*
00010  *  NOTE:
00011  *
00012  *  The buffer size should be enough to contain a string including a
00013  *  null char.
00014  *  Returns the number of bytes of the string (NOT including a null char).
00015  */
00016 
00017 TST_STRFMON tst_strfmon_loc [] = {
00018   {
00019     { Tstrfmon, TST_LOC_de },
00020     {
00021       {
00022        /* #01 */
00023        /*inp*/ { 24, "%n %% %i",        123.00                 },
00024        /*exp*/ { 0,1,23,                "123,00 EUR % 123,00 EUR"     },
00025       },
00026       {
00027        /* #02 */
00028        /*inp*/ { 24, "%n %% %i",        123.00                 },
00029        /*exp*/ { 0,1,23,                "123,00 EUR % 123,00 EUR"     },
00030       },
00031       {
00032        /* #03 */
00033        /*inp*/ { 23, "%n %% %i",        123.00                 },
00034        /*exp*/ { E2BIG,1,-1,            ""                                   },
00035       },
00036       {
00037        /* #04 */
00038        /*inp*/ { 31, "%n|%i",           1234.561                      },
00039        /*exp*/ { 0,1,25,                "1.234,56 EUR|1.234,56 EUR"},
00040       },
00041       {
00042        /* #05 */
00043        /*inp*/ { 33, "%n|%i",          -1234.561                      },
00044        /*exp*/ { 0,1,27,                "-1.234,56 EUR|-1.234,56 EUR"},
00045       },
00046       {
00047        /* #06 */
00048        /*inp*/ { 33, "%13n|%12i",       1234.561               },
00049        /*exp*/ { 0,1,26,                " 1.234,56 EUR|1.234,56 EUR"},
00050       },
00051       {
00052        /* #07 */
00053        /*inp*/ { 33, "%12n|%12i",      -1234.561               },
00054        /*exp*/ { 0,1,27,                "-1.234,56 EUR|-1.234,56 EUR"},
00055       },
00056       {
00057        /* #08 */
00058        /*inp*/ { 33, "%#5n|%#5i",       1234.561               },
00059        /*exp*/ { 0,1,29,                "  1.234,56 EUR|  1.234,56 EUR"},
00060       },
00061       {
00062        /* #09 */
00063        /*inp*/ { 33, "%#5n|%#5i",      -1234.561               },
00064        /*exp*/ { 0,1,29,                "- 1.234,56 EUR|- 1.234,56 EUR"},
00065       },
00066       {
00067        /* #10 */
00068        /*inp*/ { 33, "%=*#5n|%=*#5i",      1234.561                   },
00069        /*exp*/ { 0,1,29,                " *1.234,56 EUR| *1.234,56 EUR"},
00070       },
00071       {
00072        /* #11 */
00073        /*inp*/ { 33, "%=0#5n|%=0#5i",     -1234.561                   },
00074        /*exp*/ { 0,1,29,                "-01.234,56 EUR|-01.234,56 EUR"},
00075       },
00076       {
00077        /* #12 */
00078        /*inp*/ { 33, "%^#5n|%^#5i",       -1234.561                   },
00079        /*exp*/ { 0,1,27,                "- 1234,56 EUR|- 1234,56 EUR"},
00080       },
00081       {
00082        /* #13 */
00083        /*inp*/ { 33, "%#5.0n|%#5.0i",      1234.444                   },
00084        /*exp*/ { 0,1,23,                "  1.234 EUR|  1.234 EUR"     },
00085       },
00086       {
00087        /* #14 */
00088        /*inp*/ { 33, "%#5.0n|%#5.4i",     -1234.555                   },
00089        /*exp*/ { 0,1,28,                "- 1.235 EUR|- 1.234,5550 EUR"},
00090       },
00091       {
00092        /* #15 */
00093        /*inp*/ { 33, "%(#5n|%!(#5i",      -1234.561                   },
00094        /*exp*/ { 0,1,27,                "( 1.234,56 EUR)|( 1.234,56)"},
00095       },
00096       { .is_last = 1 }
00097     }
00098   },
00099   {
00100     { Tstrfmon, TST_LOC_enUS },
00101     {
00102       {
00103        /* #01 */
00104        /*inp*/ { 22, "%n %% %i",        123.00                 },
00105        /*exp*/ { 0,1,20,                "$123.00 % USD 123.00" },
00106       },
00107       {
00108        /* #02 */
00109        /*inp*/ { 21, "%n %% %i",        123.00                 },
00110        /*exp*/ { 0,1,20,                "$123.00 % USD 123.00" },
00111       },
00112       {
00113        /* #03 */
00114        /*inp*/ { 20, "%n %% %i",        123.00                 },
00115        /*exp*/ { E2BIG,1,-1,            ""                                   },
00116       },
00117       {
00118        /* #04 */
00119        /*inp*/ { 30, "%n|%i",           1234.561                      },
00120        /*exp*/ { 0,1,22,                "$1,234.56|USD 1,234.56"      },
00121       },
00122       {
00123        /* #05 */
00124        /*inp*/ { 32, "%n|%i",          -1234.561                      },
00125        /*exp*/ { 0,1,24,                "-$1,234.56|-USD 1,234.56"    },
00126       },
00127       {
00128        /* #06 */
00129        /*inp*/ { 30, "%12n|%12i",       1234.561               },
00130        /*exp*/ { 0,1,25,                "   $1,234.56|USD 1,234.56"},
00131       },
00132       {
00133        /* #07 */
00134        /*inp*/ { 32, "%12n|%12i",      -1234.561               },
00135        /*exp*/ { 0,1,26,                "  -$1,234.56|-USD 1,234.56"},
00136       },
00137       {
00138        /* #08 */
00139        /*inp*/ { 32, "%#5n|%#5i",       1234.561               },
00140        /*exp*/ { 0,1,26,                " $ 1,234.56| USD  1,234.56"},
00141       },
00142       {
00143        /* #09 */
00144        /*inp*/ { 32, "%#5n|%#5i",      -1234.561               },
00145        /*exp*/ { 0,1,26,                "-$ 1,234.56|-USD  1,234.56"},
00146       },
00147       {
00148        /* #10 */
00149        /*inp*/ { 32, "%=*#5n|%=*#5i",      1234.561                   },
00150        /*exp*/ { 0,1,26,                " $*1,234.56| USD *1,234.56"},
00151       },
00152       {
00153        /* #11 */
00154        /*inp*/ { 32, "%=0#5n|%=0#5i",     -1234.561                   },
00155        /*exp*/ { 0,1,26,                "-$01,234.56|-USD 01,234.56"},
00156       },
00157       {
00158        /* #12 */
00159        /*inp*/ { 32, "%^#5n|%^#5i",       -1234.561                   },
00160        /*exp*/ { 0,1,24,                "-$ 1234.56|-USD  1234.56"    },
00161       },
00162       {
00163        /* #13 */
00164        /*inp*/ { 32, "%#5.0n|%#5.0i",      1234.444                   },
00165        /*exp*/ { 0,1,20,                " $ 1,234| USD  1,234" },
00166       },
00167       {
00168        /* #14 */
00169        /*inp*/ { 32, "%#5.0n|%#5.4i",     -1234.555                   },
00170        /*exp*/ { 0,1,25,                "-$ 1,235|-USD  1,234.5550"},
00171       },
00172       {
00173        /* #15 */
00174        /*inp*/ { 32, "%(#5n|%!(#5i",      -1234.561                   },
00175        /*exp*/ { 0,1,24,                "($ 1,234.56)|( 1,234.56)"    },
00176       },
00177       { .is_last = 1 }
00178     }
00179   },
00180   {
00181     { Tstrfmon, TST_LOC_eucJP },
00182     {
00183       {
00184        /* #01 */
00185        /*inp*/ { 17, "%n %% %i",    123.00                               },
00186        /*exp*/ { 0,1,15,            "\241\357123 % JPY 123"       },
00187       },
00188       {
00189        /* #02 */
00190        /*inp*/ { 16, "%n %% %i",    123.00                               },
00191        /*exp*/ { 0,1,15,            "\241\357123 % JPY 123"       },
00192       },
00193       {
00194        /* #03 */
00195        /*inp*/ { 15, "%n %% %i",    123.00                               },
00196        /*exp*/ { E2BIG,1,-1,               ""                            },
00197       },
00198       {
00199        /* #04 */
00200        /*inp*/ { 30, "%n|%i",              1234.561                      },
00201        /*exp*/ { 0,1,17,            "\241\3571,235|JPY 1,235"     },
00202       },
00203       {
00204        /* #05 */
00205        /*inp*/ { 32, "%n|%i",             -1234.561                      },
00206        /*exp*/ { 0,1,19,            "\241\357-1,235|JPY -1,235"          },
00207       },
00208       {
00209        /* #06 */
00210        /*inp*/ { 32, "%12n|%12i",   1234.561                      },
00211        /*exp*/ { 0,1,25,            "     \241\3571,235|   JPY 1,235" },
00212       },
00213       {
00214        /* #07 */
00215        /*inp*/ { 32, "%12n|%12i",  -1234.561                      },
00216        /*exp*/ { 0,1,25,            "    \241\357-1,235|  JPY -1,235" },
00217       },
00218       {
00219        /* #08 */
00220        /*inp*/ { 32, "%#5n|%#5i",   1234.561                      },
00221        /*exp*/ { 0,1,21,            " \241\357 1,235| JPY  1,235"        },
00222       },
00223       {
00224        /* #09 */
00225        /*inp*/ { 32, "%#5n|%#5i",  -1234.561                      },
00226        /*exp*/ { 0,1,21,            "\241\357- 1,235|JPY - 1,235"        },
00227       },
00228       {
00229        /* #10 */
00230        /*inp*/ { 32, "%=*#5n|%=*#5i",      1234.561                      },
00231        /*exp*/ { 0,1,21,            " \241\357*1,235| JPY *1,235"        },
00232       },
00233       {
00234        /* #11 */
00235        /*inp*/ { 32, "%=0#5n|%=0#5i",     -1234.561                      },
00236        /*exp*/ { 0,1,21,            "\241\357-01,235|JPY -01,235"        },
00237       },
00238       {
00239        /* #12 */
00240        /*inp*/ { 32, "%^#5n|%^#5i",       -1234.561                      },
00241        /*exp*/ { 0,1,19,            "\241\357- 1235|JPY - 1235"          },
00242       },
00243       {
00244        /* #13 */
00245        /*inp*/ { 32, "%#5.0n|%#5.0i",      1234.444                      },
00246        /*exp*/ { 0,1,21,            " \241\357 1,234| JPY  1,234"        },
00247       },
00248       {
00249        /* #14 */
00250        /*inp*/ { 32, "%#5.0n|%#5.4i",     -1234.555                      },
00251        /*exp*/ { 0,1,26,            "\241\357- 1,235|JPY - 1,234.5550"},
00252       },
00253       {
00254        /* #15 */
00255        /*inp*/ { 32, "%(#5n|%!(#5i",      -1234.561                      },
00256        /*exp*/ { 0,1,19,            "(\241\357 1,235)|( 1,235)"          },
00257       },
00258       { .is_last = 1 }
00259     }
00260   },
00261   {
00262     { Tstrfmon, TST_LOC_end }
00263   }
00264 };