From 0fc8c3bbfe86007846c0589a6094668ce4cca9fe Mon Sep 17 00:00:00 2001 From: Zachy Date: Wed, 15 May 2019 13:52:13 +0100 Subject: [PATCH] Add tests for new Angle type. --- tests/test_serialization.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_serialization.py b/tests/test_serialization.py index dc07572..0daff0f 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -3,7 +3,7 @@ import unittest from minecraft.networking.types import ( Type, Boolean, UnsignedByte, Byte, Short, UnsignedShort, - Integer, FixedPointInteger, VarInt, Long, Float, Double, + Integer, FixedPointInteger, Angle, VarInt, Long, Float, Double, ShortPrefixedByteArray, VarIntPrefixedByteArray, UUID, String as StringType, Position, TrailingByteArray, UnsignedLong, ) @@ -25,6 +25,7 @@ TEST_DATA = { UnsignedLong: [0, 400], Integer: [-1000, 1000], FixedPointInteger: [float(-13098.3435), float(-0.83), float(1000)], + Angle: [0, 360.0, 90, 47.12947238973, 214.588235], VarInt: [1, 250, 50000, 10000000], Long: [50000000], Float: [21.000301], @@ -58,6 +59,9 @@ class SerializationTest(unittest.TestCase): if data_type is FixedPointInteger: self.assertAlmostEqual( test_data, deserialized, delta=1.0/32.0) + elif data_type is Angle: + print(test_data - deserialized) + self.assertAlmostEqual(test_data, deserialized, delta=360/255) elif data_type is Float or data_type is Double: self.assertAlmostEquals(test_data, deserialized, 3) else: