dat_strfmon.c 6.3 KB

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