Skip to content

Commit

Permalink
Add java.util.Map conversion property tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msteindorfer committed Oct 2, 2023
1 parent 3ffd923 commit 80927a5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/io/usethesource/capsule/AbstractMapProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;

Expand All @@ -27,6 +28,22 @@
*/
public abstract class AbstractMapProperties<T, CT extends Map.Immutable<T, T>> {

@Property(trials = DEFAULT_TRIALS)
public void convertToJavaMapAndCheckSize(CT input) {
assertEquals(new HashMap<T, T>(input).size(), input.size());
}

@Property(trials = DEFAULT_TRIALS)
public void convertToJavaMapAndCheckHashCode(CT input) {
assertEquals(new HashMap<T, T>(input).hashCode(), input.hashCode());
}

@Property(trials = DEFAULT_TRIALS)
public void convertToJavaMapAndCheckEquality(CT input) {
assertEquals("input.equals(convertToJavaSet)", input, new HashMap<T, T>(input));
assertEquals("convertToJavaSet.equals(input)", new HashMap<T, T>(input), input);
}

@Property(trials = DEFAULT_TRIALS)
public void serializationRoundtrip(CT input) throws Exception {
assertEquals(input, deserialize(serialize((Serializable) input), input.getClass()));
Expand Down

0 comments on commit 80927a5

Please sign in to comment.