dat_wcscoll.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
  3. *
  4. * FILE: dat_wcscoll.c
  5. *
  6. * WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2);
  7. */
  8. /*
  9. * CAUTION:
  10. * When LC_COLLATE (or LC_ALL) is set for ja_JP.EUC,
  11. * wcscoll() core-dumps for big values such as 0x3041
  12. * (0x0041 is okay) in glibc 2.1.2.
  13. *
  14. * NOTE:
  15. * a) When 0 is expected as a return value, set ret_flg=1.
  16. * - the return value is compared with an expected value: ret_val.
  17. * b) When a positive value is expected as a return value,
  18. * set ret_flg=0 and set cmp_flg=+1.
  19. * - the return value is not compared with the expected value
  20. * (can not be compared); instead, the test program checks
  21. * if the return value is positive when cmp_flg=+1.
  22. * c) When a negative value is expected as a return value,
  23. * ......
  24. * d) When data contains invalid values, set err_val to the expected errno.
  25. * Set ret_flg=0 and cmp_flg=0 so that it doesn't compare
  26. * the return value with an expected value or doesn't check
  27. * the sign of the return value.
  28. *
  29. *
  30. * -------------------------------------------
  31. * CASE err_val ret_flg ret_val cmp_flg
  32. * -------------------------------------------
  33. * a) 0 1 0 0
  34. * b) 0 0 0 +1
  35. * c) 0 0 0 -1
  36. * d) EINVAL 0 0 0
  37. * -------------------------------------------
  38. */
  39. TST_WCSCOLL tst_wcscoll_loc [] = {
  40. { { Twcscoll, TST_LOC_de },
  41. {
  42. { /*input.*/ { { 0x00E1,0x00E2,0x00E3,0x0000 },
  43. { 0x00E1,0x00E2,0x00E3,0x0000 }, }, /* #1 */
  44. /*expect*/ { 0,1,0, 0, },
  45. },
  46. { /*input.*/ { { 0x0000,0x00E1,0x00E3,0x0000 },
  47. { 0x0000,0x00E2,0x00E3,0x0000 }, }, /* #2 */
  48. /*expect*/ { 0,1,0, 0, },
  49. },
  50. { /*input.*/ { { 0x00E1,0x00E1,0x00E3,0x0000 },
  51. { 0x0000,0x00E2,0x00E3,0x0000 }, }, /* #3 */
  52. /*expect*/ { 0,0,0, +1, },
  53. },
  54. { /*input.*/ { { 0x0000,0x00E2,0x00E3,0x0000 },
  55. { 0x00E1,0x00E1,0x00E3,0x0000 }, }, /* #4 */
  56. /*expect*/ { 0,0,0, -1, },
  57. },
  58. { /*input.*/ { { 0x00E1,0x0042,0x00E3,0x0000 },
  59. { 0x00E1,0x0061,0x00E3,0x0000 }, }, /* #5 */
  60. /*expect*/ { 0,0,0, +1, },
  61. },
  62. { /*input.*/ { { 0x00E1,0x0061,0x00E3,0x0000 },
  63. { 0x00E1,0x0042,0x00E3,0x0000 }, }, /* #6 */
  64. /*expect*/ { 0,0,0, -1, },
  65. },
  66. { /*input.*/ { { 0x00E1,0x00E2,0x0000 },
  67. { 0x00E1,0x00E2,0x00E9,0x0000 }, }, /* #7 */
  68. /*expect*/ { 0,0,0, -1, },
  69. },
  70. { /*input.*/ { { 0x00E1,0x00E2,0x00E9,0x0000 },
  71. { 0x00E1,0x00E2,0x0000 }, }, /* #8 */
  72. /*expect*/ { 0,0,0, +1, },
  73. },
  74. { /*input.*/ { { 0x00E1,0x0092,0x00E9,0x0000 },
  75. { 0x00E1,0x008E,0x00E9,0x0000 }, }, /* #9 */
  76. /*expect*/ { 0,0,0, +1, },
  77. },
  78. { /*input.*/ { { 0x00E1,0x008E,0x00E9,0x0000 },
  79. { 0x00E1,0x0092,0x00E9,0x0000 }, }, /* #10 */
  80. /*expect*/ { 0,0,0, -1, },
  81. },
  82. { .is_last = 1 }
  83. }
  84. },
  85. { { Twcscoll, TST_LOC_en },
  86. {
  87. { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
  88. { 0x0041,0x0042,0x0043,0x0000 }, }, /* #1 */
  89. /*expect*/ { 0,1,0, 0, },
  90. },
  91. { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 },
  92. { 0x0000,0x0042,0x0043,0x0000 }, }, /* #2 */
  93. /*expect*/ { 0,1,0, 0, },
  94. },
  95. { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 },
  96. { 0x0000,0x0042,0x0043,0x0000 }, }, /* #3 */
  97. /*expect*/ { 0,0,0, +1, },
  98. },
  99. { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
  100. { 0x0041,0x0041,0x0043,0x0000 }, }, /* #4 */
  101. /*expect*/ { 0,0,0, -1, },
  102. },
  103. #ifdef SHOJI_IS_RIGHT
  104. /* <WAIVER> */ /* assume ascii */
  105. { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
  106. { 0x0041,0x0061,0x0043,0x0000 }, }, /* #5 */
  107. /*expect*/ { 0,0,0, -1, },
  108. },
  109. /* <WAIVER> */ /* assume ascii */
  110. { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
  111. { 0x0041,0x0042,0x0043,0x0000 }, }, /* #6 */
  112. /*expect*/ { 0,0,0, +1, },
  113. },
  114. #else
  115. /* XXX Correct order is lowercase before uppercase. */
  116. { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
  117. { 0x0041,0x0061,0x0043,0x0000 }, }, /* #5 */
  118. /*expect*/ { 0,0,0, +1, },
  119. },
  120. { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
  121. { 0x0041,0x0042,0x0043,0x0000 }, }, /* #6 */
  122. /*expect*/ { 0,0,0, -1, },
  123. },
  124. #endif
  125. { /*input.*/ { { 0x0041,0x0042,0x0000 },
  126. { 0x0041,0x0042,0x0049,0x0000 }, }, /* #7 */
  127. /*expect*/ { 0,0,0, -1, },
  128. },
  129. { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 },
  130. { 0x0041,0x0042,0x0000 }, }, /* #8 */
  131. /*expect*/ { 0,0,0, +1, },
  132. },
  133. #ifdef SHOJI_IS_RIGHT
  134. { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
  135. { 0x0041,0x008E,0x0049,0x0000 }, }, /* #9 */
  136. /*expect*/ { 0,0,0, +1, },
  137. },
  138. { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
  139. { 0x0041,0x0092,0x0049,0x0000 }, }, /* #10 */
  140. /*expect*/ { 0,0,0, -1, },
  141. },
  142. #else
  143. /* Do not assume position of character out of range. */
  144. { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
  145. { 0x0041,0x008E,0x0049,0x0000 }, }, /* #9 */
  146. /*expect*/ { 0,0,0, 0, },
  147. },
  148. { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
  149. { 0x0041,0x0092,0x0049,0x0000 }, }, /* #10 */
  150. /*expect*/ { 0,0,0, 0, },
  151. },
  152. #endif
  153. { .is_last = 1 }
  154. }
  155. },
  156. #if 0
  157. { { Twcscoll, TST_LOC_eucJP },
  158. #else
  159. { { Twcscoll, TST_LOC_ja_UTF8 },
  160. #endif
  161. {
  162. { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
  163. { 0x3041,0x3042,0x3043,0x0000 }, }, /* #1 */
  164. /*expect*/ { 0,1,0, 0, },
  165. },
  166. { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 },
  167. { 0x0000,0x3042,0x3043,0x0000 }, }, /* #2 */
  168. /*expect*/ { 0,1,0, 0, },
  169. },
  170. { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 },
  171. { 0x0000,0x3042,0x3043,0x0000 }, }, /* #3 */
  172. /*expect*/ { 0,0,0, +1, },
  173. },
  174. { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
  175. { 0x3041,0x3041,0x3043,0x0000 }, }, /* #4 */
  176. /*expect*/ { 0,0,0, -1, },
  177. },
  178. { /*input.*/ { { 0x3041,0x0042,0x3043,0x0000 },
  179. { 0x3041,0x0061,0x3043,0x0000 }, }, /* #5 */
  180. /*expect*/ { 0,0,0, -1, },
  181. },
  182. { /*input.*/ { { 0x3041,0x0061,0x3043,0x0000 },
  183. { 0x3041,0x0042,0x3043,0x0000 }, }, /* #6 */
  184. /*expect*/ { 0,0,0, +1, },
  185. },
  186. { /*input.*/ { { 0x3041,0x3042,0xFF71,0x0000 },
  187. { 0x3041,0x3042,0x30A2,0x0000 }, }, /* #7 */
  188. /*expect*/ { 0,0,0, -1, },
  189. },
  190. { /*input.*/ { { 0x3041,0x3042,0x30A2,0x0000 },
  191. { 0x3041,0x3042,0xFF71,0x0000 }, }, /* #8 */
  192. /*expect*/ { 0,0,0, +1, },
  193. },
  194. { /*input.*/ { { 0x30FF,0x3092,0x3049,0x0000 },
  195. { 0x3041,0x308E,0x3049,0x0000 }, }, /* #9 */
  196. /*expect*/ { 0,0,0, -1, },
  197. },
  198. { /*input.*/ { { 0x3041,0x308E,0x3049,0x0000 },
  199. { 0x30FF,0x3092,0x3049,0x0000 }, }, /* #10 */
  200. /*expect*/ { 0,0,0, +1, },
  201. },
  202. { .is_last = 1 }
  203. }
  204. },
  205. { { Twcscoll, TST_LOC_end } }
  206. };