Add tests for new Angle type.
This commit is contained in:
1 parent
7361f761f5
commit
0fc8c3bbfe
1 file changed
+5
-1
@@ -3,7 +3,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from minecraft.networking.types import (
|
from minecraft.networking.types import (
|
||||||
Type, Boolean, UnsignedByte, Byte, Short, UnsignedShort,
|
Type, Boolean, UnsignedByte, Byte, Short, UnsignedShort,
|
||||||
Integer, FixedPointInteger, VarInt, Long, Float, Double,
|
Integer, FixedPointInteger, Angle, VarInt, Long, Float, Double,
|
||||||
ShortPrefixedByteArray, VarIntPrefixedByteArray, UUID,
|
ShortPrefixedByteArray, VarIntPrefixedByteArray, UUID,
|
||||||
String as StringType, Position, TrailingByteArray, UnsignedLong,
|
String as StringType, Position, TrailingByteArray, UnsignedLong,
|
||||||
)
|
)
|
||||||
@@ -25,6 +25,7 @@ TEST_DATA = {
|
|||||||
UnsignedLong: [0, 400],
|
UnsignedLong: [0, 400],
|
||||||
Integer: [-1000, 1000],
|
Integer: [-1000, 1000],
|
||||||
FixedPointInteger: [float(-13098.3435), float(-0.83), float(1000)],
|
FixedPointInteger: [float(-13098.3435), float(-0.83), float(1000)],
|
||||||
|
Angle: [0, 360.0, 90, 47.12947238973, 214.588235],
|
||||||
VarInt: [1, 250, 50000, 10000000],
|
VarInt: [1, 250, 50000, 10000000],
|
||||||
Long: [50000000],
|
Long: [50000000],
|
||||||
Float: [21.000301],
|
Float: [21.000301],
|
||||||
@@ -58,6 +59,9 @@ class SerializationTest(unittest.TestCase):
|
|||||||
if data_type is FixedPointInteger:
|
if data_type is FixedPointInteger:
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
test_data, deserialized, delta=1.0/32.0)
|
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:
|
elif data_type is Float or data_type is Double:
|
||||||
self.assertAlmostEquals(test_data, deserialized, 3)
|
self.assertAlmostEquals(test_data, deserialized, 3)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user