home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / cintltst / cbididat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-01  |  11.7 KB  |  387 lines

  1. /*  
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright International Business Machines Corporation, 1999           *
  6. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  7. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  8. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  9. *                                                                             *
  10. *******************************************************************************
  11. *   file name:  cbididat.c
  12. *   encoding:   US-ASCII
  13. *   tab size:   8 (not used)
  14. *   indentation:4
  15. *
  16. *   created on: 1999sep22
  17. *   created by: Markus W. Scherer
  18. */
  19.  
  20. #include "utypes.h"
  21. #include "uchar.h"
  22. #include "ubidi.h"
  23. #include "cbiditst.h"
  24.  
  25. extern const char *
  26. dirPropNames[dirPropCount]={
  27.     "L", "R", "EN", "ES", "ET", "AN", "CS", "B", "S", "WS", "ON",
  28.     "LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN"
  29. };
  30.  
  31. extern const UChar
  32. charFromDirProp[dirPropCount]={
  33.  /* L     R      EN    ES    ET    AN     CS    B    S    WS    ON */
  34.     0x61, 0x5d0, 0x30, 0x2f, 0x25, 0x660, 0x2c, 0xa, 0x9, 0x20, 0x26,
  35.  /* LRE     LRO     AL     RLE     RLO     PDF     NSM    BN */
  36.     0x202a, 0x202d, 0x627, 0x202b, 0x202e, 0x202c, 0x308, 0x200c
  37. };
  38.  
  39. static const uint8_t
  40. testText1[]={
  41.     L, L, WS, L, WS, EN, L, B
  42. };
  43.  
  44. static const UBiDiLevel
  45. testLevels1[]={
  46.     0, 0, 0, 0, 0, 0, 0, 0
  47. };
  48.  
  49. static const uint8_t
  50. testVisualMap1[]={
  51.     0, 1, 2, 3, 4, 5, 6, 7
  52. };
  53.  
  54. static const uint8_t
  55. testText2[]={
  56.     R, AL, WS, R, AL, WS, R
  57. };
  58.  
  59. static const UBiDiLevel
  60. testLevels2[]={
  61.     1, 1, 1, 1, 1, 1, 1
  62. };
  63.  
  64. static const uint8_t
  65. testVisualMap2[]={
  66.     6, 5, 4, 3, 2, 1, 0
  67. };
  68.  
  69. static const uint8_t
  70. testText3[]={
  71.     L, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L
  72. };
  73.  
  74. static const UBiDiLevel
  75. testLevels3[]={
  76.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  77. };
  78.  
  79. static const uint8_t
  80. testVisualMap3[]={
  81.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
  82. };
  83.  
  84. static const uint8_t
  85. testText4[]={
  86.     L, AL, AL, AL, L, AL, AL, L, WS, EN, CS, WS, EN, CS, EN, WS, L, L
  87. };
  88.  
  89. static const UBiDiLevel
  90. testLevels4[]={
  91.     0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  92. };
  93.  
  94. static const uint8_t
  95. testVisualMap4[]={
  96.     0, 3, 2, 1, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
  97. };
  98.  
  99. static const uint8_t
  100. testText5[]={
  101.     AL, R, AL, WS, EN, CS, WS, EN, CS, EN, WS, R, R, WS, L, L
  102. };
  103.  
  104. static const UBiDiLevel
  105. testLevels5[]={
  106.     1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2
  107. };
  108.  
  109. static const uint8_t
  110. testVisualMap5[]={
  111.     15, 14, 13, 12, 11, 10, 9, 6, 7, 8, 5, 4, 3, 2, 0, 1
  112. };
  113.  
  114. static const uint8_t
  115. testText6[]={
  116.     R, EN, NSM, ET
  117. };
  118.  
  119. static const UBiDiLevel
  120. testLevels6[]={
  121.     1, 2, 2, 2
  122. };
  123.  
  124. static const uint8_t
  125. testVisualMap6[]={
  126.     3, 0, 1, 2
  127. };
  128.  
  129. #if 0
  130. static const uint8_t
  131. testText7[]={
  132.     /* empty */
  133. };
  134.  
  135. static const UBiDiLevel
  136. testLevels7[]={
  137. };
  138.  
  139. static const uint8_t
  140. testVisualMap7[]={
  141. };
  142.  
  143. #endif
  144.  
  145. static const uint8_t
  146. testText8[]={
  147.     RLE, WS, R, R, R, WS, PDF, WS, B
  148. };
  149.  
  150. static const UBiDiLevel
  151. testLevels8[]={
  152.     1, 1, 1, 1, 1, 1, 1, 1, 1
  153. };
  154.  
  155. static const uint8_t
  156. testVisualMap8[]={
  157.     8, 7, 6, 5, 4, 3, 2, 1, 0
  158. };
  159.  
  160. static const uint8_t
  161. testText9[]={
  162.     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
  163.     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
  164.     AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON
  165. };
  166.  
  167. static const UBiDiLevel
  168. testLevels9[]={
  169.     62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 61
  170. };
  171.  
  172. static const uint8_t
  173. testVisualMap9[]={
  174.     8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 7, 6, 5, 4, 3, 2, 1, 0
  175. };
  176.  
  177. static const uint8_t
  178. testText10[]={
  179.     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
  180.     LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
  181.     LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES
  182. };
  183.  
  184. static const UBiDiLevel
  185. testLevels10[]={
  186.     60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 0, 0, 62, 62, 62, 62, 60
  187. };
  188.  
  189. static const uint8_t
  190. testVisualMap10[]={
  191.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
  192. };
  193.  
  194. static const uint8_t
  195. testText11[]={
  196.     S, WS, NSM, RLE, WS, L, L, L, WS, LRO, WS, R, R, R, WS, RLO, WS, L, L,
  197.     L, WS, LRE, WS, R, R, R, WS, PDF, WS, L, L, L, WS, PDF, WS, 
  198.     AL, AL, AL, WS, PDF, WS, L, L, L, WS, PDF, WS, L, L, L, WS, PDF, 
  199.     ON, PDF, BN, BN, ON, PDF
  200. };
  201.  
  202. static const UBiDiLevel
  203. testLevels11[]={
  204.     0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  205. };
  206.  
  207. static const uint8_t
  208. testVisualMap11[]={
  209.     0, 1, 2, 44, 43, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 31, 30, 29, 28, 27, 26, 20, 21, 24, 23, 22, 25, 19, 18, 17, 16, 15, 14, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 3, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57
  210. };
  211.  
  212. static const uint8_t
  213. testText12[]={
  214.     NSM, WS, L, L, L, L, L, L, L, WS, L, L, L, L, WS, 
  215.     R, R, R, R, R, WS, L, L, L, L, L, L, L, WS, WS, AL, 
  216.     AL, AL, AL, WS, EN, EN, ES, EN, EN, CS, S, EN, EN, CS, WS, 
  217.     EN, EN, WS, AL, AL, AL, AL, AL, B, L, L, L, L, L, L, 
  218.     L, L, WS, AN, AN, CS, AN, AN, WS
  219. };
  220.  
  221. static const UBiDiLevel
  222. testLevels12[]={
  223.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
  224. };
  225.  
  226. static const uint8_t
  227. testVisualMap12[]={
  228.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
  229. };
  230.  
  231. static const UBiDiLevel
  232. testLevels13[]={
  233.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
  234. };
  235.  
  236. static const uint8_t
  237. testVisualMap13[]={
  238.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
  239. };
  240.  
  241. static const UBiDiLevel
  242. testLevels14[]={
  243.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 3, 4, 4, 3, 2, 4, 4, 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 2
  244. };
  245.  
  246. static const uint8_t
  247. testVisualMap14[]={
  248.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
  249. };
  250.  
  251. static const UBiDiLevel
  252. testLevels15[]={
  253.     5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 5
  254. };
  255.  
  256. static const uint8_t
  257. testVisualMap15[]={
  258.     69, 68, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 55, 54, 53, 52, 51, 50, 49, 42, 43, 44, 45, 46, 47, 48, 41, 40, 39, 38, 37, 36, 35, 33, 34, 32, 30, 31, 29, 28, 26, 27, 25, 24, 22, 23, 21, 20, 19, 18, 17, 16, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 1, 2, 3, 4, 5, 0
  259. };
  260.  
  261. static const UBiDiLevel
  262. testLevels16[]={
  263.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0
  264. };
  265.  
  266. static const uint8_t
  267. testVisualMap16[]={
  268.     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 39, 38, 37, 36, 34, 35, 33, 31, 32, 30, 41, 52, 53, 51, 50, 48, 49, 47, 46, 45, 44, 43, 42, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
  269. };
  270.  
  271. static const uint8_t
  272. testText13[]={
  273.     ON, L, RLO, CS, R, WS, AN, AN, PDF, LRE, R, L, LRO, WS, BN, ON, S, LRE, LRO, B
  274. };
  275.  
  276. static const UBiDiLevel
  277. testLevels17[]={
  278.     0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 3, 2, 4, 4, 4, 4, 0, 0, 0, 0
  279. };
  280.  
  281. static const uint8_t
  282. testVisualMap17[]={
  283.     0, 1, 15, 14, 13, 12, 11, 10, 4, 3, 2, 5, 6, 7, 8, 9, 16, 17, 18, 19
  284. };
  285.  
  286. static const UBiDiLevel
  287. testLevels18[]={
  288.     0, 0, 1, 1, 1, 0
  289. };
  290.  
  291. static const uint8_t
  292. testVisualMap18[]={
  293.     0, 1, 4, 3, 2, 5
  294. };
  295.  
  296. static const uint8_t
  297. testText14[]={
  298.     RLO, RLO, AL, AL, WS, EN, ES, ON, WS, S, S, PDF, LRO, WS, AL, ET, RLE, ON, EN, B
  299. };
  300.  
  301. static const UBiDiLevel
  302. testLevels19[]={
  303.     1
  304. };
  305.  
  306. static const uint8_t
  307. testVisualMap19[]={
  308.     0
  309. };
  310.  
  311. static const uint8_t
  312. testText15[]={
  313.     R, L, CS, L
  314. };
  315.  
  316. static const UBiDiLevel
  317. testLevels20[]={
  318.     2
  319. };
  320.  
  321. extern BiDiTestData
  322. tests[]={
  323.     testText1,  ARRAY_LENGTH(testText1),  UBIDI_DEFAULT_LTR, -1, -1,
  324.         UBIDI_LTR, 0,
  325.         testLevels1, testVisualMap1,
  326.     testText2,  ARRAY_LENGTH(testText2),  UBIDI_DEFAULT_LTR, -1, -1,
  327.         UBIDI_RTL, 1,
  328.         testLevels2, testVisualMap2,
  329.     testText3,  ARRAY_LENGTH(testText3),  UBIDI_DEFAULT_LTR, -1, -1,
  330.         UBIDI_LTR, 0,
  331.         testLevels3, testVisualMap3,
  332.     testText4,  ARRAY_LENGTH(testText4),  UBIDI_DEFAULT_LTR, -1, -1,
  333.         UBIDI_MIXED, 0,
  334.         testLevels4, testVisualMap4,
  335.     testText5,  ARRAY_LENGTH(testText5),  UBIDI_DEFAULT_LTR, -1, -1,
  336.         UBIDI_MIXED, 1,
  337.         testLevels5, testVisualMap5,
  338.     testText6,  ARRAY_LENGTH(testText6),  UBIDI_DEFAULT_LTR, -1, -1,
  339.         UBIDI_MIXED, 1,
  340.         testLevels6, testVisualMap6,
  341.     NULL,       0,                        UBIDI_DEFAULT_LTR, -1, -1,
  342.         UBIDI_LTR, 0,
  343.         NULL, NULL,
  344.     testText8,  ARRAY_LENGTH(testText8),  UBIDI_DEFAULT_LTR, -1, -1,
  345.         UBIDI_RTL, 1,
  346.         testLevels8, testVisualMap8,
  347.     testText9,  ARRAY_LENGTH(testText9),  UBIDI_DEFAULT_LTR, -1, -1,
  348.         UBIDI_MIXED, 0,
  349.         testLevels9, testVisualMap9,
  350.     testText10, ARRAY_LENGTH(testText10), UBIDI_DEFAULT_LTR, -1, -1,
  351.         UBIDI_MIXED, 0,
  352.         testLevels10, testVisualMap10,
  353.     testText11, ARRAY_LENGTH(testText11), UBIDI_DEFAULT_LTR, -1, -1,
  354.         UBIDI_MIXED, 0,
  355.         testLevels11, testVisualMap11,
  356.     testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_LTR, -1, -1,
  357.         UBIDI_MIXED, 0,
  358.         testLevels12, testVisualMap12,
  359.     testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_RTL, -1, -1,
  360.         UBIDI_MIXED, 0,
  361.         testLevels13, testVisualMap13,
  362.     testText12, ARRAY_LENGTH(testText12), 2, -1, -1,
  363.         UBIDI_MIXED, 2,
  364.         testLevels14, testVisualMap14,
  365.     testText12, ARRAY_LENGTH(testText12), 5, -1, -1,
  366.         UBIDI_MIXED, 5,
  367.         testLevels15, testVisualMap15,
  368.     testText12, ARRAY_LENGTH(testText12), UBIDI_DEFAULT_LTR, -1, -1,
  369.         UBIDI_MIXED, 0,
  370.         testLevels16, testVisualMap16,
  371.     testText13, ARRAY_LENGTH(testText13), UBIDI_DEFAULT_LTR, -1, -1,
  372.         UBIDI_MIXED, 0,
  373.         testLevels17, testVisualMap17,
  374.     testText13, ARRAY_LENGTH(testText13), UBIDI_DEFAULT_LTR, 0, 6,
  375.         UBIDI_MIXED, 0,
  376.         testLevels18, testVisualMap18,
  377.     testText14, ARRAY_LENGTH(testText14), UBIDI_DEFAULT_LTR, 13, 14,
  378.         UBIDI_RTL, 1,
  379.         testLevels19, testVisualMap19,
  380.     testText15, ARRAY_LENGTH(testText15), UBIDI_DEFAULT_LTR, 2, 3,
  381.         UBIDI_LTR, 2,
  382.         testLevels20, testVisualMap19
  383. };
  384.  
  385. extern int
  386. bidiTestCount=ARRAY_LENGTH(tests);
  387.