use of org.terasology.persistence.typeHandling.PersistedData in project Terasology by MovingBlocks.
the class ColorTypeHandlerTest method testDeserializeHex.
@Test
public void testDeserializeHex() {
PersistedData data = new PersistedString("DEADBEEF");
Color color = handler.deserialize(data, deserializationContext);
Assert.assertEquals(0xDEADBEEF, color.rgba());
}
use of org.terasology.persistence.typeHandling.PersistedData in project Terasology by MovingBlocks.
the class ColorTypeHandlerTest method testDeserializeArray.
@Test
public void testDeserializeArray() {
JsonArray array = new Gson().fromJson("[12, 34, 56, 78]", JsonArray.class);
PersistedData data = new GsonPersistedDataArray(array);
Color color = handler.deserialize(data, deserializationContext);
Assert.assertEquals(12, color.r());
Assert.assertEquals(34, color.g());
Assert.assertEquals(56, color.b());
Assert.assertEquals(78, color.a());
}
Aggregations