Skip to content

Commit

Permalink
Unit tests for DateSerializer and LocaleSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
serverperformance committed Aug 19, 2014
1 parent 213a767 commit 2f403c7
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/com/esotericsoftware/kryo/DefaultSerializersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import java.util.Locale;

/** @author Nathan Sweet <[email protected]> */
public class DefaultSerializersTest extends KryoTestCase {
Expand Down Expand Up @@ -155,6 +156,27 @@ public void testDateSerializer () {
roundTrip(2, 9, new Date(0));
roundTrip(4, 9, new Date(1234567));
roundTrip(10, 9, new Date(-1234567));

kryo.register(java.sql.Date.class);
roundTrip(10, 9, new java.sql.Date(Long.MIN_VALUE));
roundTrip(2, 9, new java.sql.Date(0));
roundTrip(4, 9, new java.sql.Date(1234567));
roundTrip(10, 9, new java.sql.Date(Long.MAX_VALUE));
roundTrip(10, 9, new java.sql.Date(-1234567));

kryo.register(java.sql.Time.class);
roundTrip(10, 9, new java.sql.Time(Long.MIN_VALUE));
roundTrip(2, 9, new java.sql.Time(0));
roundTrip(4, 9, new java.sql.Time(1234567));
roundTrip(10, 9, new java.sql.Time(Long.MAX_VALUE));
roundTrip(10, 9, new java.sql.Time(-1234567));

kryo.register(java.sql.Timestamp.class);
roundTrip(10, 9, new java.sql.Timestamp(Long.MIN_VALUE));
roundTrip(2, 9, new java.sql.Timestamp(0));
roundTrip(4, 9, new java.sql.Timestamp(1234567));
roundTrip(10, 9, new java.sql.Timestamp(Long.MAX_VALUE));
roundTrip(10, 9, new java.sql.Timestamp(-1234567));
}

public void testBigDecimalSerializer () {
Expand Down Expand Up @@ -278,6 +300,17 @@ public void testClassSerializer() {
assertEquals(ArrayList.class, kryo.readObject(in, Class.class));
assertEquals(TestEnum.class, kryo.readObject(in, Class.class));
}

public void testLocaleSerializer () {
kryo.setRegistrationRequired(true);
kryo.register(Locale.class);

roundTrip(5, 5, Locale.ENGLISH);
roundTrip(6, 6, Locale.US);
roundTrip(6, 6, Locale.SIMPLIFIED_CHINESE);
roundTrip(5, 5, new Locale("es"));
roundTrip(16, 16, new Locale("es", "ES", "áéíóú"));
}

public enum TestEnum {
a, b, c
Expand All @@ -291,4 +324,4 @@ public enum TestEnumWithMethods {
c {
}
}
}
}

0 comments on commit 2f403c7

Please sign in to comment.