Skip to content

Commit e072963

Browse files
committed
Tests offsets instead of rows in TextExtLocationInfo FasterXML#91
1 parent 3b17f6b commit e072963

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/test/java/stax2/stream/TestExtLocationInfo.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class TestExtLocationInfo
3535
*/
3636
final static String TEST_EXT_ENT_INCL =
3737
"<include></include>"; // first char: 0; row 1
38-
// EOF, fc: 40; row 2
38+
// EOF, fc: 19; row 1
3939

4040

4141

@@ -56,25 +56,25 @@ public Object resolveEntity(String publicID, String systemID, String baseURI, St
5656
};
5757
XMLStreamReader2 sr = getReader(TEST_EXT_ENT, URI, resolver);
5858

59-
assertRow(sr, 1, 1);
59+
assertOffset(sr, 0, 21);
6060

6161
assertTokenType(DTD, sr.next());
6262
assertTokenType(START_ELEMENT, sr.next());
6363
assertEquals("main", sr.getLocalName());
64-
assertRow(sr, 4, 4, URI);
64+
assertOffset(sr, 77, 83, URI);
6565

6666
assertTokenType(START_ELEMENT, sr.next());
6767
assertEquals("include", sr.getLocalName());
68-
assertRow(sr, 1, 1, INCL_URI);
68+
assertOffset(sr, 0, 9, INCL_URI);
6969

7070

7171

7272
assertTokenType(END_ELEMENT, sr.next());
73-
assertRow(sr, 1, 1, INCL_URI);
73+
assertOffset(sr, 9, 19, INCL_URI);
7474

7575

7676
assertTokenType(END_ELEMENT, sr.next());
77-
assertRow(sr, 4, 4, URI);
77+
assertOffset(sr, 89, 96, URI);
7878

7979
sr.close();
8080
}
@@ -85,24 +85,24 @@ public Object resolveEntity(String publicID, String systemID, String baseURI, St
8585
////////////////////////////////////////
8686
*/
8787

88-
private void assertRow(XMLStreamReader2 sr, int startRow, int endRow, String systemId)
88+
private void assertOffset(XMLStreamReader2 sr, int startOffset, int endOffset, String systemId)
8989
throws XMLStreamException
9090
{
9191
LocationInfo li = sr.getLocationInfo();
9292
Location startLoc = li.getStartLocation();
9393
assertEquals("Incorrect starting systemID for event " + tokenTypeDesc(sr.getEventType()), systemId, startLoc.getSystemId());
9494
Location endLoc = li.getEndLocation();
9595
assertEquals("Incorrect ending systemID for event " + tokenTypeDesc(sr.getEventType()), systemId, endLoc.getSystemId());
96-
assertRow(sr, startRow, endRow);
96+
assertOffset(sr, startOffset, endOffset);
9797
}
98-
private void assertRow(XMLStreamReader2 sr, int startRow, int endRow)
98+
private void assertOffset(XMLStreamReader2 sr, int startOffset, int endOffset)
9999
throws XMLStreamException
100100
{
101101
LocationInfo li = sr.getLocationInfo();
102102
Location startLoc = li.getStartLocation();
103-
assertEquals("Incorrect starting row for event "+tokenTypeDesc(sr.getEventType()), startRow, startLoc.getLineNumber());
103+
assertEquals("Incorrect starting offset for event "+tokenTypeDesc(sr.getEventType()), startOffset, startLoc.getCharacterOffset());
104104
Location endLoc = li.getEndLocation();
105-
assertEquals("Incorrect ending row for event "+tokenTypeDesc(sr.getEventType()), endRow, endLoc.getLineNumber());
105+
assertEquals("Incorrect ending offset for event "+tokenTypeDesc(sr.getEventType()), endOffset, endLoc.getCharacterOffset());
106106
}
107107

108108

0 commit comments

Comments
 (0)