graphemebreak_test.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2008 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.i18n.GraphemeBreakTest');
  15. goog.setTestOnly('goog.i18n.GraphemeBreakTest');
  16. goog.require('goog.i18n.GraphemeBreak');
  17. goog.require('goog.testing.jsunit');
  18. function testBreakNormalAscii() {
  19. assertTrue(
  20. goog.i18n.GraphemeBreak.hasGraphemeBreak(
  21. 'a'.charCodeAt(0), 'b'.charCodeAt(0), true));
  22. }
  23. function testBreakAsciiWithExtendedChar() {
  24. assertFalse(
  25. goog.i18n.GraphemeBreak.hasGraphemeBreak(
  26. 'a'.charCodeAt(0), 0x0300, true));
  27. }
  28. function testBreakSurrogates() {
  29. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0xDA00, 0xDC00, true));
  30. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0xDBFF, 0xDFFF, true));
  31. }
  32. function testBreakHangLxL() {
  33. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x1100, 0x1100, true));
  34. }
  35. function testBreakHangL_T() {
  36. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x1100, 0x11A8));
  37. }
  38. function testBreakHangLVxV() {
  39. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0xAC00, 0x1160, true));
  40. }
  41. function testBreakHangLV_L() {
  42. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0xAC00, 0x1100, true));
  43. }
  44. function testBreakHangLVTxT() {
  45. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0xAC01, 0x11A8, true));
  46. }
  47. function testBreakThaiPrependLegacy() {
  48. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x0E40, 0x0E01));
  49. }
  50. function testBreakThaiPrependExtended() {
  51. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x0E40, 0x0E01, true));
  52. }
  53. function testBreakDevaSpacingMarkLegacy() {
  54. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x0915, 0x093E));
  55. }
  56. function testBreakDevaSpacingMarkExtended() {
  57. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x0915, 0x093E, true));
  58. }
  59. function testBreakDevaViramaSpace() {
  60. assertTrue(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x094D, 0x0020));
  61. }
  62. function testBreakDevaViramaConsonant() {
  63. assertFalse(goog.i18n.GraphemeBreak.hasGraphemeBreak(0x094D, 0x0915));
  64. }