-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for DateSerializer and LocaleSerializer
- Loading branch information
1 parent
213a767
commit 2f403c7
Showing
1 changed file
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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 () { | ||
|
@@ -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 | ||
|
@@ -291,4 +324,4 @@ public enum TestEnumWithMethods { | |
c { | ||
} | ||
} | ||
} | ||
} |