aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-21 16:03:34 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-21 16:03:34 +0000
commit37f6e510aa050b356a222db149906ff0bba00a3f (patch)
treef077d1c438ef993eb809c2017e3fc9f481a10525 /src/test/java
parent5119013b30cc8f8881dc15352fe8bc69e85dbcc5 (diff)
Add basic test for FileFragmentSource::at()
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java19
1 files changed, 19 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 534f10c5..ce43303c 100644
--- a/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java
+++ b/src/test/java/org/shedlang/compiler/sources/FileFragmentSourceTests.java
@@ -1,6 +1,7 @@
package org.shedlang.compiler.sources;
import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import java.util.List;
@@ -107,4 +108,22 @@ public class FileFragmentSourceTests {
assertThat(source.describe(), equalTo(testCase.expectedContext));
})).collect(Collectors.toList());
}
+
+ @Test
+ public void atReturnsSubsectionOfCompleteSource() {
+ var source = FileFragmentSource.file("<filename>", "abcdefg");
+
+ var fragment = source.at(2, 5);
+
+ assertThat(fragment, equalTo(new FileFragmentSource("<filename>", "abcdefg", 2, 5)));
+ }
+
+ @Test
+ public void atReturnsSubsectionOfIncompleteSource() {
+ var source = FileFragmentSource.file("<filename>", "abcdefg");
+
+ var fragment = source.at(1, 6).at(1, 4);
+
+ assertThat(fragment, equalTo(new FileFragmentSource("<filename>", "abcdefg", 2, 5)));
+ }
}