Skip to content

Commit

Permalink
Add overloads of ImmutableMap.of, ImmutableBiMap.of, and `Immutab…
Browse files Browse the repository at this point in the history
…leSortedMap.of` for up to 10 entries

RELNOTES=`collect`: Added overloads of `ImmutableMap.of`, `ImmutableBiMap.of`, and `ImmutableSortedMap.of` for up to 10 entries.
PiperOrigin-RevId: 395508372
  • Loading branch information
cushon authored and Google Java Core Libraries committed Sep 8, 2021
1 parent a36f08f commit d5c30e3
Show file tree
Hide file tree
Showing 17 changed files with 2,279 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,136 @@ public void testOf() {
"four",
5,
"five");
assertMapEquals(
ImmutableBiMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6);
assertMapEquals(
ImmutableBiMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7);
assertMapEquals(
ImmutableBiMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8);
assertMapEquals(
ImmutableBiMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8,
"nine", 9),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8,
"nine",
9);
assertMapEquals(
ImmutableBiMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8,
"nine", 9,
"ten", 10),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8,
"nine",
9,
"ten",
10);
}

public void testOfNullKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,136 @@ public void testOf() {
4,
"five",
5);
assertMapEquals(
ImmutableMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6);
assertMapEquals(
ImmutableMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7);
assertMapEquals(
ImmutableMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8);
assertMapEquals(
ImmutableMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8,
"nine", 9),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8,
"nine",
9);
assertMapEquals(
ImmutableMap.of(
"one", 1,
"two", 2,
"three", 3,
"four", 4,
"five", 5,
"six", 6,
"seven", 7,
"eight", 8,
"nine", 9,
"ten", 10),
"one",
1,
"two",
2,
"three",
3,
"four",
4,
"five",
5,
"six",
6,
"seven",
7,
"eight",
8,
"nine",
9,
"ten",
10);
}

public void testOfNullKey() {
Expand Down
Loading

0 comments on commit d5c30e3

Please sign in to comment.