lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY |
| 3 | * |
| 4 | * FILE: dat_strfmon.c |
| 5 | * |
| 6 | * STRFMON: size_t strfmon (char *buf, size_t nbyte, char *fmt, ... ); |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * NOTE: |
| 11 | * |
| 12 | * The buffer size should be enough to contain a string including a |
| 13 | * null char. |
| 14 | * Returns the number of bytes of the string (NOT including a null char). |
| 15 | */ |
| 16 | |
| 17 | TST_STRFMON tst_strfmon_loc [] = { |
| 18 | { |
| 19 | { Tstrfmon, TST_LOC_de }, |
| 20 | { |
| 21 | { |
| 22 | /* #01 */ |
| 23 | /*inp*/ { 24, "%n %% %i", 123.00 }, |
| 24 | /*exp*/ { 0,1,23, "123,00 EUR % 123,00 EUR" }, |
| 25 | }, |
| 26 | { |
| 27 | /* #02 */ |
| 28 | /*inp*/ { 24, "%n %% %i", 123.00 }, |
| 29 | /*exp*/ { 0,1,23, "123,00 EUR % 123,00 EUR" }, |
| 30 | }, |
| 31 | { |
| 32 | /* #03 */ |
| 33 | /*inp*/ { 23, "%n %% %i", 123.00 }, |
| 34 | /*exp*/ { E2BIG,1,-1, "" }, |
| 35 | }, |
| 36 | { |
| 37 | /* #04 */ |
| 38 | /*inp*/ { 31, "%n|%i", 1234.561 }, |
| 39 | /*exp*/ { 0,1,25, "1.234,56 EUR|1.234,56 EUR"}, |
| 40 | }, |
| 41 | { |
| 42 | /* #05 */ |
| 43 | /*inp*/ { 33, "%n|%i", -1234.561 }, |
| 44 | /*exp*/ { 0,1,27, "-1.234,56 EUR|-1.234,56 EUR"}, |
| 45 | }, |
| 46 | { |
| 47 | /* #06 */ |
| 48 | /*inp*/ { 33, "%13n|%12i", 1234.561 }, |
| 49 | /*exp*/ { 0,1,26, " 1.234,56 EUR|1.234,56 EUR"}, |
| 50 | }, |
| 51 | { |
| 52 | /* #07 */ |
| 53 | /*inp*/ { 33, "%12n|%12i", -1234.561 }, |
| 54 | /*exp*/ { 0,1,27, "-1.234,56 EUR|-1.234,56 EUR"}, |
| 55 | }, |
| 56 | { |
| 57 | /* #08 */ |
| 58 | /*inp*/ { 33, "%#5n|%#5i", 1234.561 }, |
| 59 | /*exp*/ { 0,1,29, " 1.234,56 EUR| 1.234,56 EUR"}, |
| 60 | }, |
| 61 | { |
| 62 | /* #09 */ |
| 63 | /*inp*/ { 33, "%#5n|%#5i", -1234.561 }, |
| 64 | /*exp*/ { 0,1,29, "- 1.234,56 EUR|- 1.234,56 EUR"}, |
| 65 | }, |
| 66 | { |
| 67 | /* #10 */ |
| 68 | /*inp*/ { 33, "%=*#5n|%=*#5i", 1234.561 }, |
| 69 | /*exp*/ { 0,1,29, " *1.234,56 EUR| *1.234,56 EUR"}, |
| 70 | }, |
| 71 | { |
| 72 | /* #11 */ |
| 73 | /*inp*/ { 33, "%=0#5n|%=0#5i", -1234.561 }, |
| 74 | /*exp*/ { 0,1,29, "-01.234,56 EUR|-01.234,56 EUR"}, |
| 75 | }, |
| 76 | { |
| 77 | /* #12 */ |
| 78 | /*inp*/ { 33, "%^#5n|%^#5i", -1234.561 }, |
| 79 | /*exp*/ { 0,1,27, "- 1234,56 EUR|- 1234,56 EUR"}, |
| 80 | }, |
| 81 | { |
| 82 | /* #13 */ |
| 83 | /*inp*/ { 33, "%#5.0n|%#5.0i", 1234.444 }, |
| 84 | /*exp*/ { 0,1,23, " 1.234 EUR| 1.234 EUR" }, |
| 85 | }, |
| 86 | { |
| 87 | /* #14 */ |
| 88 | /*inp*/ { 33, "%#5.0n|%#5.4i", -1234.555 }, |
| 89 | /*exp*/ { 0,1,28, "- 1.235 EUR|- 1.234,5550 EUR"}, |
| 90 | }, |
| 91 | { |
| 92 | /* #15 */ |
| 93 | /*inp*/ { 33, "%(#5n|%!(#5i", -1234.561 }, |
| 94 | /*exp*/ { 0,1,27, "( 1.234,56 EUR)|( 1.234,56)"}, |
| 95 | }, |
| 96 | { .is_last = 1 } |
| 97 | } |
| 98 | }, |
| 99 | { |
| 100 | { Tstrfmon, TST_LOC_enUS }, |
| 101 | { |
| 102 | { |
| 103 | /* #01 */ |
| 104 | /*inp*/ { 22, "%n %% %i", 123.00 }, |
| 105 | /*exp*/ { 0,1,20, "$123.00 % USD 123.00" }, |
| 106 | }, |
| 107 | { |
| 108 | /* #02 */ |
| 109 | /*inp*/ { 21, "%n %% %i", 123.00 }, |
| 110 | /*exp*/ { 0,1,20, "$123.00 % USD 123.00" }, |
| 111 | }, |
| 112 | { |
| 113 | /* #03 */ |
| 114 | /*inp*/ { 20, "%n %% %i", 123.00 }, |
| 115 | /*exp*/ { E2BIG,1,-1, "" }, |
| 116 | }, |
| 117 | { |
| 118 | /* #04 */ |
| 119 | /*inp*/ { 30, "%n|%i", 1234.561 }, |
| 120 | /*exp*/ { 0,1,22, "$1,234.56|USD 1,234.56" }, |
| 121 | }, |
| 122 | { |
| 123 | /* #05 */ |
| 124 | /*inp*/ { 32, "%n|%i", -1234.561 }, |
| 125 | /*exp*/ { 0,1,24, "-$1,234.56|-USD 1,234.56" }, |
| 126 | }, |
| 127 | { |
| 128 | /* #06 */ |
| 129 | /*inp*/ { 30, "%12n|%12i", 1234.561 }, |
| 130 | /*exp*/ { 0,1,25, " $1,234.56|USD 1,234.56"}, |
| 131 | }, |
| 132 | { |
| 133 | /* #07 */ |
| 134 | /*inp*/ { 32, "%12n|%12i", -1234.561 }, |
| 135 | /*exp*/ { 0,1,26, " -$1,234.56|-USD 1,234.56"}, |
| 136 | }, |
| 137 | { |
| 138 | /* #08 */ |
| 139 | /*inp*/ { 32, "%#5n|%#5i", 1234.561 }, |
| 140 | /*exp*/ { 0,1,26, " $ 1,234.56| USD 1,234.56"}, |
| 141 | }, |
| 142 | { |
| 143 | /* #09 */ |
| 144 | /*inp*/ { 32, "%#5n|%#5i", -1234.561 }, |
| 145 | /*exp*/ { 0,1,26, "-$ 1,234.56|-USD 1,234.56"}, |
| 146 | }, |
| 147 | { |
| 148 | /* #10 */ |
| 149 | /*inp*/ { 32, "%=*#5n|%=*#5i", 1234.561 }, |
| 150 | /*exp*/ { 0,1,26, " $*1,234.56| USD *1,234.56"}, |
| 151 | }, |
| 152 | { |
| 153 | /* #11 */ |
| 154 | /*inp*/ { 32, "%=0#5n|%=0#5i", -1234.561 }, |
| 155 | /*exp*/ { 0,1,26, "-$01,234.56|-USD 01,234.56"}, |
| 156 | }, |
| 157 | { |
| 158 | /* #12 */ |
| 159 | /*inp*/ { 32, "%^#5n|%^#5i", -1234.561 }, |
| 160 | /*exp*/ { 0,1,24, "-$ 1234.56|-USD 1234.56" }, |
| 161 | }, |
| 162 | { |
| 163 | /* #13 */ |
| 164 | /*inp*/ { 32, "%#5.0n|%#5.0i", 1234.444 }, |
| 165 | /*exp*/ { 0,1,20, " $ 1,234| USD 1,234" }, |
| 166 | }, |
| 167 | { |
| 168 | /* #14 */ |
| 169 | /*inp*/ { 32, "%#5.0n|%#5.4i", -1234.555 }, |
| 170 | /*exp*/ { 0,1,25, "-$ 1,235|-USD 1,234.5550"}, |
| 171 | }, |
| 172 | { |
| 173 | /* #15 */ |
| 174 | /*inp*/ { 32, "%(#5n|%!(#5i", -1234.561 }, |
| 175 | /*exp*/ { 0,1,24, "($ 1,234.56)|( 1,234.56)" }, |
| 176 | }, |
| 177 | { .is_last = 1 } |
| 178 | } |
| 179 | }, |
| 180 | { |
| 181 | #if 0 |
| 182 | { Tstrfmon, TST_LOC_eucJP }, |
| 183 | #else |
| 184 | { Tstrfmon, TST_LOC_ja_UTF8 }, |
| 185 | #endif |
| 186 | { |
| 187 | { |
| 188 | /* #01 */ |
| 189 | /*inp*/ { 17, "%n %% %i", 123.00 }, |
| 190 | /*exp*/ { 0,1,15, "\241\357123 % JPY 123" }, |
| 191 | }, |
| 192 | { |
| 193 | /* #02 */ |
| 194 | /*inp*/ { 16, "%n %% %i", 123.00 }, |
| 195 | /*exp*/ { 0,1,15, "\241\357123 % JPY 123" }, |
| 196 | }, |
| 197 | { |
| 198 | /* #03 */ |
| 199 | /*inp*/ { 15, "%n %% %i", 123.00 }, |
| 200 | /*exp*/ { E2BIG,1,-1, "" }, |
| 201 | }, |
| 202 | { |
| 203 | /* #04 */ |
| 204 | /*inp*/ { 30, "%n|%i", 1234.561 }, |
| 205 | /*exp*/ { 0,1,17, "\241\3571,235|JPY 1,235" }, |
| 206 | }, |
| 207 | { |
| 208 | /* #05 */ |
| 209 | /*inp*/ { 32, "%n|%i", -1234.561 }, |
| 210 | /*exp*/ { 0,1,19, "\241\357-1,235|JPY -1,235" }, |
| 211 | }, |
| 212 | { |
| 213 | /* #06 */ |
| 214 | /*inp*/ { 32, "%12n|%12i", 1234.561 }, |
| 215 | /*exp*/ { 0,1,25, " \241\3571,235| JPY 1,235" }, |
| 216 | }, |
| 217 | { |
| 218 | /* #07 */ |
| 219 | /*inp*/ { 32, "%12n|%12i", -1234.561 }, |
| 220 | /*exp*/ { 0,1,25, " \241\357-1,235| JPY -1,235" }, |
| 221 | }, |
| 222 | { |
| 223 | /* #08 */ |
| 224 | /*inp*/ { 32, "%#5n|%#5i", 1234.561 }, |
| 225 | /*exp*/ { 0,1,21, " \241\357 1,235| JPY 1,235" }, |
| 226 | }, |
| 227 | { |
| 228 | /* #09 */ |
| 229 | /*inp*/ { 32, "%#5n|%#5i", -1234.561 }, |
| 230 | /*exp*/ { 0,1,21, "\241\357- 1,235|JPY - 1,235" }, |
| 231 | }, |
| 232 | { |
| 233 | /* #10 */ |
| 234 | /*inp*/ { 32, "%=*#5n|%=*#5i", 1234.561 }, |
| 235 | /*exp*/ { 0,1,21, " \241\357*1,235| JPY *1,235" }, |
| 236 | }, |
| 237 | { |
| 238 | /* #11 */ |
| 239 | /*inp*/ { 32, "%=0#5n|%=0#5i", -1234.561 }, |
| 240 | /*exp*/ { 0,1,21, "\241\357-01,235|JPY -01,235" }, |
| 241 | }, |
| 242 | { |
| 243 | /* #12 */ |
| 244 | /*inp*/ { 32, "%^#5n|%^#5i", -1234.561 }, |
| 245 | /*exp*/ { 0,1,19, "\241\357- 1235|JPY - 1235" }, |
| 246 | }, |
| 247 | { |
| 248 | /* #13 */ |
| 249 | /*inp*/ { 32, "%#5.0n|%#5.0i", 1234.444 }, |
| 250 | /*exp*/ { 0,1,21, " \241\357 1,234| JPY 1,234" }, |
| 251 | }, |
| 252 | { |
| 253 | /* #14 */ |
| 254 | /*inp*/ { 32, "%#5.0n|%#5.4i", -1234.555 }, |
| 255 | /*exp*/ { 0,1,26, "\241\357- 1,235|JPY - 1,234.5550"}, |
| 256 | }, |
| 257 | { |
| 258 | /* #15 */ |
| 259 | /*inp*/ { 32, "%(#5n|%!(#5i", -1234.561 }, |
| 260 | /*exp*/ { 0,1,19, "(\241\357 1,235)|( 1,235)" }, |
| 261 | }, |
| 262 | { .is_last = 1 } |
| 263 | } |
| 264 | }, |
| 265 | { |
| 266 | { Tstrfmon, TST_LOC_end } |
| 267 | } |
| 268 | }; |