mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-12-23 00:57:47 +01:00
Add tests for new Angle type.
This commit is contained in:
parent
7361f761f5
commit
0fc8c3bbfe
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user