MCPcopy
hub / github.com/libgdx/libgdx / unicodeTest

Method unicodeTest

gdx/test/com/badlogic/gdx/utils/CharArrayTest.java:716–740  ·  view source on GitHub ↗

Test Unicode/code point methods

()

Source from the content-addressed store, hash-verified

714
715 /** Test Unicode/code point methods */
716 @Test
717 public void unicodeTest () {
718 CharArray array = new CharArray();
719
720 // Append code point (emoji)
721 int smiley = 0x1F600; // 😀
722 array.appendCodePoint(smiley);
723 Assert.assertEquals(2, array.size); // Surrogate pair
724
725 // Code point at
726 int cp = array.codePointAt(0);
727 Assert.assertEquals(smiley, cp);
728
729 // Code point count
730 array.append("Hello");
731 int count = array.codePointCount(0, array.size);
732 Assert.assertEquals(6, count); // 1 emoji + 5 chars
733
734 // Reverse with code points
735 CharArray array2 = new CharArray();
736 array2.appendCodePoint(0x1F600); // 😀
737 array2.append("Hi");
738 array2.reverseCodePoints();
739 Assert.assertEquals("iH", array2.substring(0, 2));
740 }
741
742 /** Test iterator methods */
743 @Test

Callers

nothing calls this directly

Calls 7

appendCodePointMethod · 0.95
codePointAtMethod · 0.95
appendMethod · 0.95
codePointCountMethod · 0.95
reverseCodePointsMethod · 0.95
substringMethod · 0.95
assertEqualsMethod · 0.45

Tested by

no test coverage detected