Skip to content

Commit

Permalink
Added tests for ClassValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Jul 3, 2018
1 parent 66436f1 commit 0675395
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/com/esotericsoftware/kryo/serializers/GenericsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.junit.Before;
import org.junit.Test;
import org.objenesis.strategy.StdInstantiatorStrategy;

public class GenericsTest extends KryoTestCase {
{
Expand Down Expand Up @@ -79,6 +80,31 @@ public void testDifferentTypeArguments () {
kryo.writeClassAndObject(buffer, o2);
}

@Test
public void testClassValue () {
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
roundTrip(Integer.MIN_VALUE, new SomeClassValue());
}

@Test
public void testClassValueAnon () {
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
ClassValue<Boolean> value = new ClassValue<Boolean>() {
protected Boolean computeValue (Class type) {
return true;
}

public boolean equals (Object obj) {
return true;
}
};
roundTrip(Integer.MIN_VALUE, value);
}

private interface Holder<V> {
V getValue ();
}
Expand Down Expand Up @@ -205,4 +231,14 @@ public ConcreteClass (final List listPayload) {
super(listPayload);
}
}

static public class SomeClassValue extends ClassValue<Boolean> {
protected Boolean computeValue (Class type) {
return true;
}

public boolean equals (Object obj) {
return true;
}
}
}

0 comments on commit 0675395

Please sign in to comment.