From 76c4122664096b8947cdc7c36ebbc1b7bf8941bb Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Sat, 21 Sep 2024 02:19:16 +0200 Subject: [PATCH] Fix line numbers for invariant test failures --- .../java/org/unicode/text/UCD/TestUnicodeInvariants.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java b/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java index ac507c58ed..c14f487219 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java @@ -184,7 +184,7 @@ public static int testInvariants(String inputFile, String suffix, boolean doRang } final var noComments = new StringBuilder(); final List lines = new ArrayList<>(); - final List lineBeginnings = new ArrayList(); + final List lineBeginnings = new ArrayList<>(); try (final BufferedReader in = getInputReader(inputFile)) { in.lines() .forEach( @@ -233,8 +233,8 @@ public static int testInvariants(String inputFile, String suffix, boolean doRang final Function getLineNumber = position -> { for (int i = 0; i < lineBeginnings.size(); ++i) { - if (lineBeginnings.get(i) > position.getIndex()) { - return i; // 1-based line number. + if (lineBeginnings.get(i) >= position.getIndex()) { + return i + 1; // 1-based line number. } } return lineBeginnings.size();