Skip to content

Commit

Permalink
Adjust AutoValueTest so that it covers setting an immutable collectio…
Browse files Browse the repository at this point in the history
…n of T from a Collection<? extends T>. The actual bug was fixed long ago but never closed and never covered by an explicit test.

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201956399
  • Loading branch information
eamonnmcmanus authored and cushon committed Jun 26, 2018
1 parent 1a6c9fe commit fd6c6fa
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2189,13 +2189,13 @@ public void testBuilderWithExoticPropertyBuilders() {
public abstract static class BuilderWithCopyingSetters<T extends Number> {
public abstract ImmutableSet<? extends T> things();

public abstract ImmutableList<String> strings();
public abstract ImmutableList<Number> numbers();

public abstract ImmutableMap<String, T> map();

public static <T extends Number> Builder<T> builder(T value) {
return new AutoValue_AutoValueTest_BuilderWithCopyingSetters.Builder<T>()
.setStrings(ImmutableSet.of("foo", "bar"))
.setNumbers(ImmutableSet.of(17, 23.0))
.setMap(Collections.singletonMap("foo", value));
}

Expand All @@ -2207,7 +2207,7 @@ public interface Builder<T extends Number> {

Builder<T> setThings(T... things);

Builder<T> setStrings(Collection<String> strings);
Builder<T> setNumbers(Collection<? extends Number> strings);

Builder<T> setMap(Map<String, T> map);

Expand All @@ -2221,7 +2221,7 @@ public void testBuilderWithCopyingSetters() {

BuilderWithCopyingSetters<Integer> a = builder.setThings(ImmutableSet.of(1, 2)).build();
assertEquals(ImmutableSet.of(1, 2), a.things());
assertEquals(ImmutableList.of("foo", "bar"), a.strings());
assertEquals(ImmutableList.of(17, 23.0), a.numbers());
assertEquals(ImmutableMap.of("foo", 23), a.map());

BuilderWithCopyingSetters<Integer> b = builder.setThings(Arrays.asList(1, 2)).build();
Expand Down

0 comments on commit fd6c6fa

Please sign in to comment.