MCPcopy Create free account
hub / github.com/JetBrains/skija / testAbc

Method testAbc

tests/java/TextLineTest.java:23–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 }
22
23 public void testAbc() {
24 try (TextLine line = TextLine.make("abc", inter36);) {
25 assertArrayEquals(new short[] {503, 574, 581}, line.getGlyphs());
26 assertArrayEquals(new int[] {0, 1, 2, 3}, TextLine._nGetBreakOffsets(line._ptr));
27 assertArrayEquals(new float[] {0f, 20f, 42f, 62f}, TextLine._nGetBreakPositions(line._ptr));
28
29 pushStack("getOffsetAtCoord");
30 assertEquals(0, line.getOffsetAtCoord(-10f)); // before “a”
31
32 assertEquals(0, line.getOffsetAtCoord(0f)); // beginning of “a”
33 assertEquals(0, line.getOffsetAtCoord(5f)); // left half of “a”
34 assertEquals(1, line.getOffsetAtCoord(10f)); // center of “a”
35 assertEquals(1, line.getOffsetAtCoord(15f)); // right half of “a”
36
37 assertEquals(1, line.getOffsetAtCoord(20f)); // between “a” and “b”
38 assertEquals(1, line.getOffsetAtCoord(25f)); // left half of “b”
39 assertEquals(2, line.getOffsetAtCoord(31f)); // center of “b”
40 assertEquals(2, line.getOffsetAtCoord(36f)); // right half of “b”
41
42 assertEquals(2, line.getOffsetAtCoord(42f)); // between “b” and “c”
43 assertEquals(2, line.getOffsetAtCoord(47f)); // left half of “c”
44 assertEquals(3, line.getOffsetAtCoord(52f)); // center of “c”
45 assertEquals(3, line.getOffsetAtCoord(57f)); // right half of “c”
46
47 assertEquals(3, line.getOffsetAtCoord(62f)); // end of “c”
48 assertEquals(3, line.getOffsetAtCoord(100f)); // after “c”
49 popStack();
50
51 pushStack("getLeftOffsetAtCoord");
52 assertEquals(0, line.getLeftOffsetAtCoord(-10f)); // before “a”
53
54 assertEquals(0, line.getLeftOffsetAtCoord(0f)); // beginning of “a”
55 assertEquals(0, line.getLeftOffsetAtCoord(5f)); // left half of “a”
56 assertEquals(0, line.getLeftOffsetAtCoord(10f)); // center of “a”
57 assertEquals(0, line.getLeftOffsetAtCoord(15f)); // right half of “a”
58
59 assertEquals(1, line.getLeftOffsetAtCoord(20f)); // between “a” and “b”
60 assertEquals(1, line.getLeftOffsetAtCoord(25f)); // left half of “b”
61 assertEquals(1, line.getLeftOffsetAtCoord(31f)); // center of “b”
62 assertEquals(1, line.getLeftOffsetAtCoord(36f)); // right half of “b”
63
64 assertEquals(2, line.getLeftOffsetAtCoord(42f)); // between “b” and “c”
65 assertEquals(2, line.getLeftOffsetAtCoord(47f)); // left half of “c”
66 assertEquals(2, line.getLeftOffsetAtCoord(52f)); // center of “c”
67 assertEquals(2, line.getLeftOffsetAtCoord(57f)); // right half of “c”
68
69 assertEquals(3, line.getLeftOffsetAtCoord(62f)); // end of “c”
70 assertEquals(3, line.getLeftOffsetAtCoord(100f)); // after “c”
71 popStack();
72
73 pushStack("getCoordAtOffset");
74 assertClose(0f, line.getCoordAtOffset(0));
75 assertClose(20f, line.getCoordAtOffset(1));
76 assertClose(42f, line.getCoordAtOffset(2));
77 assertClose(62f, line.getCoordAtOffset(3));
78 popStack();
79 }
80 }

Callers 1

executeMethod · 0.95

Calls 12

makeMethod · 0.95
_nGetBreakOffsetsMethod · 0.95
_nGetBreakPositionsMethod · 0.95
assertArrayEqualsMethod · 0.80
pushStackMethod · 0.80
assertEqualsMethod · 0.80
getOffsetAtCoordMethod · 0.80
popStackMethod · 0.80
getLeftOffsetAtCoordMethod · 0.80
assertCloseMethod · 0.80
getCoordAtOffsetMethod · 0.80
getGlyphsMethod · 0.45

Tested by

no test coverage detected