aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-21 16:06:03 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-21 16:06:03 +0000
commit8a4e269a1ecd0092c82e3fccbe7af9baf09fdf1e (patch)
treee841b7c64528cbe198af5cc7b17ef3aba03250bb /src/test/java
parent37f6e510aa050b356a222db149906ff0bba00a3f (diff)
Check that character range is valid
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java b/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java
index ce43303c..c0d7684a 100644
--- a/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java
+++ b/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.equalTo;
@@ -126,4 +127,16 @@ public class FileFragmentSourceTests {
assertThat(fragment, equalTo(new FileFragmentSource("<filename>", "abcdefg", 2, 5)));
}
+
+ @Test
+ public void whenAtIsCalledWithEndBeforeStartThenErrorIsThrown() {
+ var source = FileFragmentSource.file("<filename>", "abcdefg");
+
+ var error = assertThrows(
+ IllegalArgumentException.class,
+ () -> source.at(2, 1)
+ );
+
+ assertThat(error.getMessage(), equalTo("characterIndexStart > characterIndexEnd"));
+ }
}