Skip to content

Commit

Permalink
Added more tests for the closure
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman committed Jan 12, 2024
1 parent 862e33e commit ac07452
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,47 @@ public void deepClosure(IValueFactory vf) {
assertEquals(slowClosure(vf, r),r.closure(),() -> "Failed with input: " + r.toString());
}

@ParameterizedTest @ArgumentsSource(ValueProvider.class)
public void broadClosure(IValueFactory vf) {
IValue prev = vf.integer(0);
var rBuilder = vf.setWriter();
for (int i=1; i < 100; i++) {
IValue next = vf.integer(i);
if (i % 5 != 0) {
rBuilder.appendTuple(prev, next);
}
prev = next;
}
var r = rBuilder.done().asRelation();

assertEquals(slowClosure(vf, r),r.closure(),() -> "Failed with input: " + r.toString());
}

@ParameterizedTest @ArgumentsSource(ValueProvider.class)
public void severalDeep(IValueFactory vf) {
IValue prev = vf.integer(0);
var rBuilder = vf.setWriter();
for (int i=1; i < 100; i++) {
IValue next = vf.integer(i);
if (i % 50 != 0) {
rBuilder.appendTuple(prev, next);
}
prev = next;
}
// now let's add some side paths
prev = vf.integer(10);
for (int i=11; i < 100; i+=2) {
IValue next = vf.integer(i);
if (i % 50 != 0) {
rBuilder.appendTuple(prev, next);
}
prev = next;
}
var r = rBuilder.done().asRelation();

assertEquals(slowClosure(vf, r),r.closure(),() -> "Failed with input: " + r.toString());
}

private ISet slowClosure(IValueFactory vf, IRelation<ISet> r) {
var prev = vf.set();
ISet result = r.asContainer();
Expand Down

0 comments on commit ac07452

Please sign in to comment.