unicode.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include "test.h"
  2. /*
  3. * g_unichar_type
  4. */
  5. RESULT
  6. test_g_unichar_type ()
  7. {
  8. if (g_unichar_type ('A') != G_UNICODE_UPPERCASE_LETTER)
  9. return FAILED ("#1");
  10. if (g_unichar_type ('a') != G_UNICODE_LOWERCASE_LETTER)
  11. return FAILED ("#2");
  12. if (g_unichar_type ('1') != G_UNICODE_DECIMAL_NUMBER)
  13. return FAILED ("#3");
  14. if (g_unichar_type (0xA3) != G_UNICODE_CURRENCY_SYMBOL)
  15. return FAILED ("#4");
  16. return NULL;
  17. }
  18. /*
  19. * g_unichar_toupper
  20. */
  21. RESULT
  22. test_g_unichar_toupper ()
  23. {
  24. if (g_unichar_toupper (0) != 0)
  25. return FAILED ("#0");
  26. if (g_unichar_toupper ('a') != 'A')
  27. return FAILED ("#1");
  28. if (g_unichar_toupper ('1') != '1')
  29. return FAILED ("#2");
  30. if (g_unichar_toupper (0x1C4) != 0x1C4)
  31. return FAILED ("#3");
  32. if (g_unichar_toupper (0x1F2) != 0x1F1)
  33. return FAILED ("#4");
  34. if (g_unichar_toupper (0x1F3) != 0x1F1)
  35. return FAILED ("#5");
  36. if (g_unichar_toupper (0xFFFF) != 0xFFFF)
  37. return FAILED ("#6");
  38. if (g_unichar_toupper (0x10428) != 0x10400)
  39. return FAILED ("#7");
  40. return NULL;
  41. }
  42. /*
  43. * g_unichar_tolower
  44. */
  45. RESULT
  46. test_g_unichar_tolower ()
  47. {
  48. if (g_unichar_tolower (0) != 0)
  49. return FAILED ("#0");
  50. if (g_unichar_tolower ('A') != 'a')
  51. return FAILED ("#1");
  52. if (g_unichar_tolower ('1') != '1')
  53. return FAILED ("#2");
  54. if (g_unichar_tolower (0x1C5) != 0x1C6)
  55. return FAILED ("#3");
  56. if (g_unichar_tolower (0x1F1) != 0x1F3)
  57. return FAILED ("#4");
  58. if (g_unichar_tolower (0x1F2) != 0x1F3)
  59. return FAILED ("#5");
  60. if (g_unichar_tolower (0xFFFF) != 0xFFFF)
  61. return FAILED ("#6");
  62. return NULL;
  63. }
  64. /*
  65. * g_unichar_totitle
  66. */
  67. RESULT
  68. test_g_unichar_totitle ()
  69. {
  70. if (g_unichar_toupper (0) != 0)
  71. return FAILED ("#0");
  72. if (g_unichar_totitle ('a') != 'A')
  73. return FAILED ("#1");
  74. if (g_unichar_totitle ('1') != '1')
  75. return FAILED ("#2");
  76. if (g_unichar_totitle (0x1C4) != 0x1C5)
  77. return FAILED ("#3");
  78. if (g_unichar_totitle (0x1F2) != 0x1F2)
  79. return FAILED ("#4");
  80. if (g_unichar_totitle (0x1F3) != 0x1F2)
  81. return FAILED ("#5");
  82. if (g_unichar_toupper (0xFFFF) != 0xFFFF)
  83. return FAILED ("#6");
  84. return NULL;
  85. }
  86. static Test unicode_tests [] = {
  87. {"g_unichar_type", test_g_unichar_type},
  88. {"g_unichar_toupper", test_g_unichar_toupper},
  89. {"g_unichar_tolower", test_g_unichar_tolower},
  90. {"g_unichar_totitle", test_g_unichar_totitle},
  91. {NULL, NULL}
  92. };
  93. DEFINE_TEST_GROUP_INIT(unicode_tests_init, unicode_tests)