updated unit tests
This commit is contained in:
parent
73ee71105c
commit
cba890c623
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package dorkbox.serializers;
|
package dorkbox.serializers;
|
||||||
|
|
||||||
import static dorkbox.serializers.KryoTest.deserialize;
|
|
||||||
import static dorkbox.serializers.KryoTest.serialize;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -54,9 +52,9 @@ public class SubListSerializersTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doTest(final List<TestEnum> subList) {
|
private void doTest(final List<TestEnum> subList) {
|
||||||
final byte[] serialized = serialize( _kryo, subList );
|
final byte[] serialized = KryoTest.Companion.serialize( _kryo, subList );
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
final List<TestEnum> deserialized = deserialize( _kryo, serialized, subList.getClass() );
|
final List<TestEnum> deserialized = KryoTest.Companion.deserialize( _kryo, serialized, subList.getClass() );
|
||||||
|
|
||||||
assertEquals( deserialized, subList );
|
assertEquals( deserialized, subList );
|
||||||
assertEquals( deserialized.remove( 0 ), subList.remove( 0 ) );
|
assertEquals( deserialized.remove( 0 ), subList.remove( 0 ) );
|
||||||
@ -122,9 +120,9 @@ public class SubListSerializersTest {
|
|||||||
final List<String> mylist = arrayList("1", "1", "2", "1", "1");
|
final List<String> mylist = arrayList("1", "1", "2", "1", "1");
|
||||||
final List<String> subList = mylist.subList(0, 5);
|
final List<String> subList = mylist.subList(0, 5);
|
||||||
|
|
||||||
final byte[] serialized = serialize( _kryo, subList );
|
final byte[] serialized = KryoTest.Companion.serialize( _kryo, subList );
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
final List<String> deserialized = deserialize( _kryo, serialized, subList.getClass() );
|
final List<String> deserialized = KryoTest.Companion.deserialize( _kryo, serialized, subList.getClass() );
|
||||||
|
|
||||||
assertEquals( deserialized, subList );
|
assertEquals( deserialized, subList );
|
||||||
assertEquals( deserialized, mylist );
|
assertEquals( deserialized, mylist );
|
||||||
@ -143,8 +141,8 @@ public class SubListSerializersTest {
|
|||||||
|
|
||||||
final List<List<String>> lists = new ArrayList<List<String>>(Arrays.asList(l1s1, l1s2, l2s1, l1, l2));
|
final List<List<String>> lists = new ArrayList<List<String>>(Arrays.asList(l1s1, l1s2, l2s1, l1, l2));
|
||||||
|
|
||||||
final byte[] serialized = serialize( _kryo, lists );
|
final byte[] serialized = KryoTest.Companion.serialize( _kryo, lists );
|
||||||
final List<List<String>> deserialized = deserialize( _kryo, serialized, lists.getClass() );
|
final List<List<String>> deserialized = KryoTest.Companion.deserialize( _kryo, serialized, lists.getClass() );
|
||||||
|
|
||||||
assertEquals( deserialized, lists );
|
assertEquals( deserialized, lists );
|
||||||
}
|
}
|
||||||
@ -162,8 +160,8 @@ public class SubListSerializersTest {
|
|||||||
|
|
||||||
final List<List<String>> lists = new ArrayList<List<String>>(Arrays.asList(l1, l2, l1s1, l1s2, l2s1));
|
final List<List<String>> lists = new ArrayList<List<String>>(Arrays.asList(l1, l2, l1s1, l1s2, l2s1));
|
||||||
|
|
||||||
final byte[] serialized = serialize( _kryo, lists );
|
final byte[] serialized = KryoTest.Companion.serialize( _kryo, lists );
|
||||||
final List<List<String>> deserialized = deserialize( _kryo, serialized, lists.getClass() );
|
final List<List<String>> deserialized = KryoTest.Companion.deserialize( _kryo, serialized, lists.getClass() );
|
||||||
|
|
||||||
assertEquals( deserialized, lists );
|
assertEquals( deserialized, lists );
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -140,9 +140,7 @@ public class TestClasses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public static class Person implements Serializable {
|
public static class Person {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public enum Gender {
|
public enum Gender {
|
||||||
MALE,
|
MALE,
|
||||||
@ -195,11 +193,6 @@ public class TestClasses {
|
|||||||
return _friends;
|
return _friends;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param friends
|
|
||||||
* @param friends2
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean flatEquals( final Collection<?> c1, final Collection<?> c2 ) {
|
private boolean flatEquals( final Collection<?> c1, final Collection<?> c2 ) {
|
||||||
return c1 == c2 || c1 != null && c2 != null && c1.size() == c2.size();
|
return c1 == c2 || c1 != null && c2 != null && c1.size() == c2.size();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package dorkbox.serializers;
|
package dorkbox.serializers;
|
||||||
|
|
||||||
import static dorkbox.serializers.KryoTest.deserialize;
|
|
||||||
import static dorkbox.serializers.KryoTest.serialize;
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
|
||||||
@ -62,15 +60,15 @@ public class UnicodeBlockSerializerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicRoundTrip() {
|
public void testBasicRoundTrip() {
|
||||||
byte[] serialized = serialize(kryo, UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS);
|
byte[] serialized = KryoTest.Companion.serialize(kryo, UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS);
|
||||||
assertSame(deserialize(kryo, serialized, UnicodeBlock.class),
|
assertSame(KryoTest.Companion.deserialize(kryo, serialized, UnicodeBlock.class),
|
||||||
UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS);
|
UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserializingUnknownInstanceReturnsNull() {
|
public void testDeserializingUnknownInstanceReturnsNull() {
|
||||||
byte[] serialized = serialize(kryo, new ObjenesisStd().newInstance(UnicodeBlock.class));
|
byte[] serialized = KryoTest.Companion.serialize(kryo, new ObjenesisStd().newInstance(UnicodeBlock.class));
|
||||||
assertNull(deserialize(kryo, serialized, UnicodeBlock.class));
|
assertNull(KryoTest.Companion.deserialize(kryo, serialized, UnicodeBlock.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user