Skip to content
Permalink
Browse files

fix formatting for missing/extra elements in iterable

  • Loading branch information...
elucash committed Jul 18, 2019
1 parent 938f3c1 commit 373461081b72283e92875b6988999c4760e76201
Showing with 10 additions and 4 deletions.
  1. +4 −4 mod/that/src/io/immutables/that/That.java
  2. +6 −0 mod/that/test/io/immutables/that/TestThat.java
@@ -552,16 +552,16 @@ default void hasOnly(java.lang.Iterable<T> elements) {
}

if (!missingElements.isEmpty() || !remainingElements.isEmpty()) {
java.lang.String actual = "";
List<java.lang.String> actual = new ArrayList<>();
if (!missingElements.isEmpty()) {
actual += "missing " + What.showElements(missingElements) + "; ";
actual.add("missing " + What.showElements(missingElements));
}
if (!remainingElements.isEmpty()) {
actual += "extra " + What.showElements(remainingElements);
actual.add("extra " + What.showElements(remainingElements));
}
throw What.newAssertionError(
"expected only: " + What.showElements(expectedElements),
"actual: " + actual);
"actual: " + java.lang.String.join("; ", actual));
}
}
}
@@ -1,5 +1,6 @@
package io.immutables.that;

import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import static io.immutables.that.Assert.that;
@@ -45,4 +46,9 @@ public void assertEmptyHasSize() {
public void assertJustSame() {
that("a").just().same(new String("a"));
}

@Test(expected = AssertionError.class)
public void assertHasOnly() {
that(Arrays.asList("a", "b", "c", "d")).hasOnly("a", "b", "h", "d");
}
}

0 comments on commit 3734610

Please sign in to comment.
You can’t perform that action at this time.