Skip to content

Commit

Permalink
#415: Add test to Selection to test an empty graph for the getAllScop…
Browse files Browse the repository at this point in the history
…edValues.

It is tested indirectly by calling getAllValues with scope parameters.
  • Loading branch information
mvanaken committed Mar 18, 2024
1 parent 395d9de commit 0e83127
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import static io.parsingdata.metal.Shorthand.rep;
import static io.parsingdata.metal.data.ParseGraph.EMPTY;
import static io.parsingdata.metal.data.Selection.NO_LIMIT;
import static io.parsingdata.metal.data.Selection.findItemAtOffset;
import static io.parsingdata.metal.data.Selection.getAllValues;
import static io.parsingdata.metal.util.EncodingFactory.enc;
Expand Down Expand Up @@ -54,7 +56,7 @@ private Source createSource() {
@Test
public void findItemAtOffsetTest() {
assertEquals("the_one",
findItemAtOffset(ImmutableList.create(ParseGraph.EMPTY.add(new ParseValue("two", any("a"), Slice.createFromSource(source, BigInteger.valueOf(2), BigInteger.valueOf(2)).get(), enc()))
findItemAtOffset(ImmutableList.create(EMPTY.add(new ParseValue("two", any("a"), Slice.createFromSource(source, BigInteger.valueOf(2), BigInteger.valueOf(2)).get(), enc()))
.add(new ParseValue("zero", any("a"), Slice.createFromSource(source, ZERO, BigInteger.valueOf(2)).get(), enc()))
.add(new ParseValue("the_one", any("a"), Slice.createFromSource(source, ONE, BigInteger.valueOf(2)).get(), enc()))), ZERO, source).computeResult().get().asGraph().head.asValue().name);
assertEquals("zero",
Expand All @@ -72,4 +74,9 @@ public void limit() {
}
}

@Test
public void emptyGraph() {
assertEquals(0, getAllValues(EMPTY, (value) -> true, NO_LIMIT, 2, 0).size);
}

}

0 comments on commit 0e83127

Please sign in to comment.