Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Sep 6, 2024
1 parent 1f496d7 commit 921bbb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gson/src/test/java/com/google/gson/GsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public String toString() {
+ " but got instance of class java.lang.Integer\n"
+ "Verify that the adapter was registed for the correct type.");

// Returning boxed object should be allowed (e.g. returning `Integer` for `int`)
// Returning boxed primitive should be allowed (e.g. returning `Integer` for `int`)
Gson gson2 = new GsonBuilder().registerTypeAdapter(int.class, new IntegerAdapter()).create();
assertThat(gson2.fromJson("0", int.class)).isEqualTo(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,12 @@ public void testStringMapCreation() {

// But when explicitly requesting a `LinkedHashMap<String, ...>` should use JDK `LinkedHashMap`
actual =
constructorConstructor
.get(TypeToken.getParameterized(LinkedHashMap.class, String.class, Integer.class))
.construct();
constructorConstructor.get(new TypeToken<LinkedHashMap<String, Integer>>() {}).construct();
assertThat(actual).isInstanceOf(LinkedHashMap.class);

// For all Map types with non-String key, should use JDK `LinkedHashMap` by default
actual =
constructorConstructor
.get(TypeToken.getParameterized(Map.class, Integer.class, Integer.class))
.construct();
constructorConstructor.get(new TypeToken<LinkedHashMap<Integer, Integer>>() {}).construct();
assertThat(actual).isInstanceOf(LinkedHashMap.class);
}

Expand Down

0 comments on commit 921bbb4

Please sign in to comment.