Files
panda3d/tests/linmath/test_lvector4.py
Leandro (Cerberus1746) Benedet Garcia 12f8363284 linmath: support round(), floor(), ceil() in vector classes
Closes #821
2019-12-30 03:06:00 +01:00

39 lines
1.0 KiB
Python

from math import floor, ceil
import sys
import pytest
from panda3d.core import Vec4
original_vector = Vec4(2.3, -2.6, 3.5, 1)
reason = '''Rounding in Python 2.7 expects to return a float value, since it returns a Vector it
does not work. When Python 2.7 gets deprecated, remove this check.'''
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_round():
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 4
assert rounded_vector.w == 1
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_floor():
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 3
assert rounded_vector.w == 1
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_ceil():
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
assert rounded_vector.z == 4
assert rounded_vector.w == 1