Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private StringSubject doFactValue(@Nullable String key, @Nullable Integer index)
fact("but contained multiple", factsWithName));
return ignoreCheck().that("");
}
if (index != null && index > factsWithName.size()) {
if (index != null && index >= factsWithName.size()) {
failWithoutActual(
fact("for key", key),
fact("index too high", index),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ public void factValueIntFailNotEnoughWithKey() {
assertFailureValue(e, "fact count was", "1");
}

@Test
public void factValueIntFailIndexEqualsCount() {
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(failure(fact("foo", "the foo"))).factValue("foo", 1));
assertFailureKeys(e, "for key", "index too high", "fact count was");
assertFailureValue(e, "for key", "foo");
assertFailureValue(e, "index too high", "1");
assertFailureValue(e, "fact count was", "1");
}

@Test
public void factValueIntFailNoValue() {
AssertionError e =
Expand Down
Loading