Skip to content

Commit

Permalink
[DO NOT MERGE] Test for google/gson#2729
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubomyr-shaydariv committed Sep 5, 2024
1 parent d9163ba commit 6a64d30
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/java/com/google/gson/TypeAdapterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.google.gson;

import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class TypeAdapterTest {

@Test
public void testTypeAdapterNullSafe() {
final TypeAdapter<?> unit = typeAdapter;
final TypeAdapter<?> nullSafeUnit1 = unit.nullSafe();
final TypeAdapter<?> nullSafeUnit2 = unit.nullSafe();
Assertions.assertNotSame(nullSafeUnit1, nullSafeUnit2);
Assertions.assertSame(nullSafeUnit1, nullSafeUnit2.nullSafe(), () -> String.format("Must pass the test once %s is resolved", "https://github.com/google/gson/issues/2729"));
Assertions.assertSame(nullSafeUnit1.nullSafe(), nullSafeUnit2, () -> String.format("Must pass the test once %s is resolved", "https://github.com/google/gson/issues/2729"));
}

private static final TypeAdapter<Object> typeAdapter = new TypeAdapter<>() {
@Override
public void write(final JsonWriter out, final Object value) {
throw new AssertionError();
}

@Override
public Object read(final JsonReader in) {
throw new AssertionError();
}
};

}
4 changes: 4 additions & 0 deletions src/test/java/com/google/gson/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@Nonnull
package com.google.gson;

import javax.annotation.Nonnull;

0 comments on commit 6a64d30

Please sign in to comment.