dat_swscanf.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
  3. *
  4. * FILE: dat_swscanf.c
  5. *
  6. * SWSCANF: int swscanf (const wchar_t *s, const wchar_t *fmt, ...);
  7. */
  8. #include <errno.h>
  9. #include <stdlib.h>
  10. #include "tst_types.h"
  11. #include "tgn_locdef.h"
  12. TST_SWSCANF tst_swscanf_loc [] =
  13. {
  14. {
  15. { Tswscanf, TST_LOC_de },
  16. {
  17. /*------------------------ 01 -----------------------*/
  18. { { {
  19. 0x002D, 0x0031, 0x003A, /* %d: -1 */
  20. 0x0032, 0x003A, /* %u: 2 */
  21. 0x0033, 0x002C, 0x0033, 0x003A, /* %f: 3.3 */
  22. 0x00E4, 0x003A, /* %c: 'ä' */
  23. 0x00C4, 0x00DC, 0x0000, 0x0000, /* %s: "ÄÜ" */
  24. },
  25. L"%d:%u:%f:%c:%s", 0
  26. },
  27. { /* The fields are: err_val, ret_flag, ret_val,
  28. val_int, val_uns, val_flt, val_c, val_s, val_S. */
  29. 0,1,5,
  30. -1, 2, 3.3, 'ä', "ÄÜ", { 0x0000, },
  31. },
  32. },
  33. /*------------------------ 02 -----------------------*/
  34. { { {
  35. 0x00E4, 0x00C4, 0x0000 /* "äÄ" */
  36. },
  37. L"%lc", 'C'
  38. },
  39. { 0,1,1,
  40. 0,0,0,0,"", { 0x00E4, 0x0000 },
  41. },
  42. },
  43. /*------------------------ 03 -----------------------*/
  44. { { {
  45. 0x00E4, 0x00C4, 0x0000 /* "äÄ" */
  46. },
  47. L"%ls", 'S'
  48. },
  49. { 0,1,1,
  50. 0,0,0,0,"", { 0x00E4, 0x00C4, 0x0000 },
  51. },
  52. },
  53. /*------------------------ 04 -----------------------*/
  54. /* <NO_WAIVER> x 2 */
  55. { { {
  56. 0x00E4, 0x00C4, 0x0000 /* "äÄ" */
  57. },
  58. L"1%d:2%d:3%d:4%d:5%d:6%d:7%d:8%d:9%d", 0
  59. },
  60. #ifdef SHOJI_IS_RIGHT
  61. { 1,EINVAL,1,WEOF,
  62. 0,0,0,0,"", { 0x0000 },
  63. #else
  64. { 0,1,0,
  65. 0,0,0,0,"", { 0x0000 },
  66. #endif
  67. },
  68. },
  69. /*---------------------------------------------------*/
  70. { .is_last = 1} /* Last element. */
  71. }
  72. },
  73. {
  74. { Tswscanf, TST_LOC_enUS },
  75. {
  76. /*------------------------ 01 -----------------------*/
  77. { { { 0x002D, 0x0031, 0x003A,
  78. 0x0032, 0x003A,
  79. 0x0035, 0x0034, 0x002E, 0x0033, 0x0045, 0x002D, 0x0031, 0x003A,
  80. 0x0041, 0x003A,
  81. 0x0061, 0x0062, 0x0000, 0x0000,
  82. },
  83. L"%d:%u:%f:%c:%s", 0
  84. },
  85. { 0,1,5,
  86. -1, 2, 5.43, 'A', "ab", { 0x0000 },
  87. },
  88. },
  89. /*------------------------ 02 -----------------------*/
  90. /* <NO_WAIVER> x 2 */
  91. { { {
  92. 0x0063, 0x0064, 0x0000
  93. },
  94. L"%C", 'C'
  95. },
  96. { 0,1,1,
  97. 0,0,0,0,"", { 0x0063, 0x0000 },
  98. },
  99. },
  100. /*------------------------ 03 -----------------------*/
  101. { { {
  102. 0x0063, 0x0064, 0x0000
  103. },
  104. L"%S", 'S'
  105. },
  106. { 0,1,1,
  107. 0,0,0,0,"", { 0x0063, 0x0064, 0x0000 },
  108. },
  109. },
  110. /*---------------------------------------------------*/
  111. { .is_last = 1} /* Last element. */
  112. }
  113. },
  114. {
  115. #if 0
  116. { Tswscanf, TST_LOC_eucJP },
  117. #else
  118. { Tswscanf, TST_LOC_ja_UTF8 },
  119. #endif
  120. {
  121. /*------------------------ 01 -----------------------*/
  122. { { { 0x002D, 0x0031, 0x003A,
  123. 0x0032, 0x003A,
  124. 0x0033, 0x002E, 0x0033, 0x003A,
  125. 0x0062, 0x003A,
  126. 0x0061, 0x0062, 0x0000, 0x0000,
  127. },
  128. L"%d:%u:%f:%c:%s", 0
  129. },
  130. { 0,1,5,
  131. -1, 2, 3.3, 'b', "ab", { 0x0000 }
  132. },
  133. },
  134. /*------------------------ 02 -----------------------*/
  135. { { {
  136. 0x30A2, 0x30A4, 0x0000
  137. },
  138. L"%ls", 'S'
  139. },
  140. { 0,1,1,
  141. 0,0,0,0,"", { 0x30A2, 0x30A4, 0x0000 }
  142. },
  143. },
  144. /*------------------------ 03 -----------------------*/
  145. { { {
  146. 0x0031, 0x003A,
  147. 0x0030, 0x003A,
  148. 0x0033, 0x002E, 0x0039, 0x003A,
  149. 0x0061, 0x003A,
  150. 0x0063, 0x0064, 0x0000, 0x0000,
  151. },
  152. L"%2$d:%1$u:%3$f:%4$c:%5$s", 0
  153. },
  154. { 0,1,5,
  155. 0, 1, 3.9, 'a', "cd", { 0x0000 }
  156. },
  157. },
  158. #ifdef SHOJI_IS_RIGHT
  159. /* XXX This test does not make sense. The format string is
  160. L"\x1\x2\x25\x53" and it is supposed to match the words
  161. 0x30A2, 0x30A4, 0x0001. */
  162. /*------------------------ 04 -----------------------*/
  163. /* <NO_WAIVER> x 2 */
  164. { { {
  165. 0x30A2, 0x30A4, 0x0001, 0x0000
  166. },
  167. { 0x0001,0x0002,0x0025,0x0053,0x0000 }, 'S'
  168. },
  169. { EILSEQ,1,EOF,
  170. 0,0,0,0,"", { 0x0000 }
  171. },
  172. },
  173. #endif
  174. /*---------------------------------------------------*/
  175. { .is_last = 1} /* Last element. */
  176. }
  177. },
  178. {
  179. { Tswscanf, TST_LOC_end }
  180. }
  181. };