chr.slt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Return NULL for NULL input
  10. query T
  11. SELECT chr(NULL)
  12. ----
  13. NULL
  14. query error null character not permitted
  15. SELECT chr(0)
  16. # Match behavior of Postgres 14
  17. query error requested character too large for encoding: -1
  18. SELECT chr(-1)
  19. # i32.MIN
  20. query error requested character too large for encoding: -2147483648
  21. SELECT chr(-2147483648)
  22. # Test non-printable characters
  23. query T
  24. SELECT chr(1) = E'\u0001'
  25. ----
  26. true
  27. query T
  28. SELECT chr(2) = E'\u0002'
  29. ----
  30. true
  31. query T
  32. SELECT chr(10) = E'\u000a'
  33. ----
  34. true
  35. query T
  36. SELECT chr(126)
  37. ----
  38. ~
  39. query T
  40. SELECT chr(127) = E'\u007f'
  41. ----
  42. true
  43. # Check if non-ASCII characters work
  44. query T
  45. SELECT chr(128) = E'\u0080'
  46. ----
  47. true
  48. # Test random basic multilingual plane (BMP) character
  49. query T
  50. SELECT chr(9233)
  51. ----
  52. # Last code point before the surrogates
  53. query T
  54. SELECT chr(55295)
  55. ----
  56. # Surrogate characters should not be encoded in UTF-8
  57. # 55296 = U+D800
  58. query error requested character not valid for encoding: 55296
  59. SELECT chr(55296)
  60. # Last surrogate character
  61. # 57343 = U+DFFF
  62. query error requested character not valid for encoding: 57343
  63. SELECT chr(57343)
  64. query T
  65. SELECT chr(57344)
  66. ----
  67. # Test full and half width characters
  68. query T
  69. SELECT chr(65318)
  70. ----
  71. query T
  72. SELECT chr(65383)
  73. ----
  74. # Test supplementary multilingual plane (SMP / Plane 1) characters
  75. query T
  76. SELECT chr(66312)
  77. ----
  78. 𐌈
  79. query T
  80. SELECT chr(92330)
  81. ----
  82. 𖢪
  83. query T
  84. SELECT chr(128579)
  85. ----
  86. 🙃
  87. # Test composing regional indicator symbols
  88. query T
  89. SELECT chr(127463) || chr(127479);
  90. ----
  91. 🇧🇷
  92. # Test supplementary ideographic plane (SIP / Plane 2) characters
  93. query T
  94. SELECT chr(194564)
  95. ----
  96. 你
  97. # Test last valid Unicode code point
  98. query T
  99. SELECT chr(1114111) = E'\U0010FFFF'
  100. ----
  101. true
  102. # First invalid code point
  103. query error requested character too large for encoding: 1114112
  104. SELECT chr(1114112)
  105. # i32.MAX
  106. query error requested character too large for encoding: 2147483647
  107. SELECT chr(2147483647)