Search in sources :

Example 1 with InMemoryPersistedDataSerializer

use of org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer in project Terasology by MovingBlocks.

the class SimpleCoreHandlerTest method serialization.

@ParameterizedTest(name = "{1}")
@DisplayName("Check simple core types serialization")
@MethodSource("primitives")
<T> void serialization(T obj, TypeHandler<T> typeHandler, PersistedData expectedData) throws Exception {
    PersistedData data = typeHandler.serialize(obj, new InMemoryPersistedDataSerializer());
    Assertions.assertEquals(expectedData.getClass(), data.getClass());
    Assertions.assertEquals(getData(expectedData), getData(data));
}
Also used : InMemoryPersistedDataSerializer(org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer) PersistedData(org.terasology.persistence.typeHandling.PersistedData) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with InMemoryPersistedDataSerializer

use of org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer in project Terasology by MovingBlocks.

the class CharacterTypeHandlerTest method testSerialize.

@Test
void testSerialize() {
    PersistedDataSerializer serializer = new InMemoryPersistedDataSerializer();
    char linefeedChar = '\n';
    PersistedData data = typeHandler.serializeNonNull(linefeedChar, serializer);
    Assertions.assertEquals("\n", data.getAsString());
}
Also used : InMemoryPersistedDataSerializer(org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer) PersistedDataSerializer(org.terasology.persistence.typeHandling.PersistedDataSerializer) InMemoryPersistedDataSerializer(org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer) PersistedData(org.terasology.persistence.typeHandling.PersistedData) Test(org.junit.jupiter.api.Test)

Aggregations

PersistedData (org.terasology.persistence.typeHandling.PersistedData)2 InMemoryPersistedDataSerializer (org.terasology.persistence.typeHandling.inMemory.InMemoryPersistedDataSerializer)2 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 PersistedDataSerializer (org.terasology.persistence.typeHandling.PersistedDataSerializer)1