dat_strcoll.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
  3. *
  4. * FILE: dat_strcoll.c
  5. *
  6. * STRCOLL: int strcoll (const char *s1, const char *s2);
  7. */
  8. /*
  9. NOTE:
  10. If a return value is expected to be 0, set ret_flg=1 and the
  11. expected value = 0. If a return value is expected to be a
  12. positive/negative value, set ret_flg=0, and set the expected value
  13. = +1/-1.
  14. There is inconsistensy between tst_strcoll() and tst_wcscoll()(it
  15. has cmp_flg) for input data. I'll fix it.
  16. Assuming en_US to be en_US.ascii. (maybe, should be iso8859-1).
  17. ASCII CODE : A,B,C, ... , a, b, c, ... B,a:-1 a,B:+1
  18. DICTIONARY : A,a,B,b,C,c,.... a,B:-1 B,a:+1 */
  19. TST_STRCOLL tst_strcoll_loc [] = {
  20. {
  21. { Tstrcoll, TST_LOC_de },
  22. {
  23. { /*input.*/ { "ÄBCDEFG", "ÄBCDEFG" }, /* #1 */
  24. /*expect*/ { 0,1,0, },
  25. },
  26. { /*input.*/ { "XX Ä XX", "XX B XX" }, /* #2 */
  27. /*expect*/ { 0,0,-1, },
  28. },
  29. { /*input.*/ { "XX B XX", "XX Ä XX" }, /* #3 */
  30. /*expect*/ { 0,0,+1, },
  31. },
  32. { /*input.*/ { "B", "a" }, /* #4 */
  33. /*expect*/ { 0,0,+1, },
  34. },
  35. { /*input.*/ { "a", "B" }, /* #5 */
  36. /*expect*/ { 0,0,-1, },
  37. },
  38. { /*input.*/ { "b", "A" }, /* #6 */
  39. /*expect*/ { 0,0,+1, },
  40. },
  41. { /*input.*/ { "A", "b" }, /* #7 */
  42. /*expect*/ { 0,0,-1, },
  43. },
  44. { /*input.*/ { "ä", "B" }, /* #8 */
  45. /*expect*/ { 0,0,-1, },
  46. },
  47. { /*input.*/ { "B", "ä" }, /* #9 */
  48. /*expect*/ { 0,0,+1, },
  49. },
  50. { .is_last = 1 } /* Last element. */
  51. }
  52. },
  53. {
  54. { Tstrcoll, TST_LOC_en },
  55. {
  56. { /*input.*/ { "ABCDEFG", "ABCDEFG" }, /* #1 */
  57. /*expect*/ { 0,1,0, },
  58. },
  59. { /*input.*/ { "XX a XX", "XX B XX" }, /* #2 */
  60. /*expect*/ { 0,0,-1, },
  61. },
  62. { /*input.*/ { "XX B XX", "XX a XX" }, /* #3 */
  63. /*expect*/ { 0,0,+1, },
  64. },
  65. {
  66. /* <WAIVER> */
  67. /*input.*/ { "B", "a" }, /* #4 */
  68. #ifdef SHOJI_IS_RIGHT
  69. /*expect*/ { 0,0,-1, },
  70. #else
  71. /* XXX We are not testing the C locale. */
  72. /*expect*/ { 0,0,+1, },
  73. #endif
  74. },
  75. {
  76. /* <WAIVER> */
  77. /*input.*/ { "a", "B" }, /* #5 */
  78. #ifdef SHOJI_IS_RIGHT
  79. /*expect*/ { 0,0,+1, },
  80. #else
  81. /* XXX We are not testing the C locale. */
  82. /*expect*/ { 0,0,-1, },
  83. #endif
  84. },
  85. { /*input.*/ { "b", "A" }, /* #6 */
  86. /*expect*/ { 0,0,+1, },
  87. },
  88. { /*input.*/ { "A", "b" }, /* #7 */
  89. /*expect*/ { 0,0,-1, },
  90. },
  91. #ifdef NO_WAIVER
  92. /* XXX I do not yet know whether strcoll really should reject
  93. characters outside the multibyte character range. */
  94. {
  95. /* #8 */ /* <WAIVER> */
  96. /*input.*/ { "\244\242\244\244\244\246\244\250\244\252", "ABCDEFG" },
  97. /*expect*/ { EINVAL,0,0, },
  98. },
  99. {
  100. /* #9 */ /* <WAIVER> */
  101. /*input.*/ { "ABCZEFG", "\244\242\244\244\244\246\244\250\244\252" },
  102. /*expect*/ { EINVAL,0,0, },
  103. },
  104. #endif
  105. { .is_last = 1 } /* Last element. */
  106. }
  107. },
  108. #if 0
  109. {
  110. { Tstrcoll, TST_LOC_eucJP },
  111. {
  112. { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
  113. "\244\242\244\244\244\246\244\250\244\252" }, /* #1 */
  114. /*expect*/ { 0,1,0, },
  115. },
  116. { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
  117. "\244\242\244\244\244\363\244\250\244\252" }, /* #2 */
  118. /*expect*/ { 0,0,-1, },
  119. },
  120. { /*input.*/ { "\244\242\244\244\244\363\244\250\244\252",
  121. "\244\242\244\244\244\246\244\250\244\252" }, /* #3 */
  122. /*expect*/ { 0,0,+1, },
  123. },
  124. { /*input.*/ { "B", "a" }, /* #4 */
  125. /*expect*/ { 0,0,-1, },
  126. },
  127. { /*input.*/ { "a", "B" }, /* #5 */
  128. /*expect*/ { 0,0,+1, },
  129. },
  130. { /*input.*/ { "b", "A" }, /* #6 */
  131. /*expect*/ { 0,0,+1, },
  132. },
  133. { /*input.*/ { "A", "b" }, /* #7 */
  134. /*expect*/ { 0,0,-1, },
  135. },
  136. #ifdef NO_WAIVER
  137. /* XXX I do not yet know whether strcoll really should reject
  138. characters outside the multibyte character range. */
  139. {
  140. /* <WAIVER> */
  141. /*input.*/ { "\200\216\217", "ABCDEFG" }, /* #8 */
  142. /*expect*/ { EINVAL,0,0, },
  143. },
  144. {
  145. /* <WAIVER> */
  146. /*input.*/ { "ABCZEFG", "\200\216\217" }, /* #9 */
  147. /*expect*/ { EINVAL,0,0, },
  148. },
  149. #endif
  150. { .is_last = 1 } /* Last element. */
  151. }
  152. },
  153. #else
  154. {
  155. { Tstrcoll, TST_LOC_ja_UTF8 },
  156. {
  157. { /*input.*/ { "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212",
  158. "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212" }, /* #1 */
  159. /*expect*/ { 0,1,0, },
  160. },
  161. { /*input.*/ { "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212",
  162. "\343\201\202\343\201\204\343\202\223\343\201\210\343\201\212" }, /* #2 */
  163. /*expect*/ { 0,0,-1, },
  164. },
  165. { /*input.*/ { "\343\201\202\343\201\204\343\202\223\343\201\210\343\201\212",
  166. "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212" }, /* #3 */
  167. /*expect*/ { 0,0,+1, },
  168. },
  169. { /*input.*/ { "B", "a" }, /* #4 */
  170. /*expect*/ { 0,0,-1, },
  171. },
  172. { /*input.*/ { "a", "B" }, /* #5 */
  173. /*expect*/ { 0,0,+1, },
  174. },
  175. { /*input.*/ { "b", "A" }, /* #6 */
  176. /*expect*/ { 0,0,+1, },
  177. },
  178. { /*input.*/ { "A", "b" }, /* #7 */
  179. /*expect*/ { 0,0,-1, },
  180. },
  181. #ifdef NO_WAIVER
  182. /* XXX I do not yet know whether strcoll really should reject
  183. characters outside the multibyte character range. */
  184. {
  185. /* <WAIVER> */
  186. /*input.*/ { "\200\216\217", "ABCDEFG" }, /* #8 */
  187. /*expect*/ { EINVAL,0,0, },
  188. },
  189. {
  190. /* <WAIVER> */
  191. /*input.*/ { "ABCZEFG", "\200\216\217" }, /* #9 */
  192. /*expect*/ { EINVAL,0,0, },
  193. },
  194. #endif
  195. { .is_last = 1 } /* Last element. */
  196. }
  197. },
  198. #endif
  199. {
  200. { Tstrcoll, TST_LOC_end }
  201. }
  202. };