diff --git a/core/src/main/java/com/google/common/truth/IterableSubject.java b/core/src/main/java/com/google/common/truth/IterableSubject.java index 6fb291249..352fecee0 100644 --- a/core/src/main/java/com/google/common/truth/IterableSubject.java +++ b/core/src/main/java/com/google/common/truth/IterableSubject.java @@ -619,8 +619,8 @@ public Ordered containsExactlyElementsIn(Iterable expected) { // We know they don't correspond in order, so we're going to have to do an any-order test. // Find a many:many mapping between the indexes of the elements which correspond, and check // it for completeness. - ImmutableList actualList = ImmutableList.copyOf(getCastSubject()); - ImmutableList expectedList = ImmutableList.copyOf(expected); + List actualList = Lists.newArrayList(getCastSubject()); + List expectedList = Lists.newArrayList(expected); ImmutableSetMultimap candidateMapping = findCandidateMapping(actualList, expectedList); failIfCandidateMappingHasMissingOrExtra(actualList, expectedList, candidateMapping); @@ -681,8 +681,8 @@ void failIfCandidateMappingHasMissingOrExtra( List actual, List expected, ImmutableMultimap mapping) { - ImmutableList extra = findNotIndexed(actual, mapping.keySet()); - ImmutableList missing = findNotIndexed(expected, mapping.inverse().keySet()); + List extra = findNotIndexed(actual, mapping.keySet()); + List missing = findNotIndexed(expected, mapping.inverse().keySet()); Optional missingOrExtraMessage = describeMissingOrExtra(extra, missing); if (missingOrExtraMessage.isPresent()) { failWithRawMessage( @@ -721,19 +721,19 @@ private Optional describeMissingOrExtra( * Returns all the elements of the given list other than those with the given indexes. Assumes * that all the given indexes really are valid indexes into the list. */ - private ImmutableList findNotIndexed(List list, Set indexes) { + private List findNotIndexed(List list, Set indexes) { if (indexes.size() == list.size()) { // If there are as many distinct valid indexes are there are elements in the list then every // index must be in there once. return ImmutableList.of(); } - ImmutableList.Builder notIndexed = ImmutableList.builder(); + List notIndexed = Lists.newArrayList(); for (int index = 0; index < list.size(); index++) { if (!indexes.contains(index)) { notIndexed.add(list.get(index)); } } - return notIndexed.build(); + return notIndexed; } /** @@ -786,8 +786,8 @@ void failIfOneToOneMappingHasMissingOrExtra( List actual, List expected, BiMap mapping) { - ImmutableList extra = findNotIndexed(actual, mapping.keySet()); - ImmutableList missing = findNotIndexed(expected, mapping.inverse().keySet()); + List extra = findNotIndexed(actual, mapping.keySet()); + List missing = findNotIndexed(expected, mapping.inverse().keySet()); Optional missingOrExtraMessage = describeMissingOrExtra(extra, missing); if (missingOrExtraMessage.isPresent()) { failWithRawMessage( diff --git a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java index 37c57a363..9b373e990 100644 --- a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java @@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; @@ -1258,12 +1257,11 @@ public void comparingElementsUsing_containsExactlyElementsIn_inOrder_failsOutOfO @Test public void comparingElementsUsing_containsExactlyElementsIn_null() { - List expected = Arrays.asList((Integer) null); - List actual = Arrays.asList((String) null); + List expected = Arrays.asList(128, null); + List actual = Arrays.asList(null, "0x80"); assertThat(actual) .comparingElementsUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) - .containsExactlyElementsIn(expected) - .inOrder(); + .containsExactlyElementsIn(expected); } @Test @@ -1309,11 +1307,10 @@ public void comparingElementsUsing_containsExactly_failsMissingAndExtraInOneToOn @Test public void comparingElementsUsing_containsExactly_nullValueInArray() { - List actual = Arrays.asList((String) null); + List actual = Arrays.asList(null, "0x80"); assertThat(actual) .comparingElementsUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) - .containsExactly((Integer) null) - .inOrder(); + .containsExactly(128, null); } @Test