python_arango_ogm.utils.test_math_util
1import pytest 2 3from python_arango_ogm.utils.math_util import Vector2d, Rect2d, lerp 4 5 6def test_vector(): 7 v1 = Vector2d(3, 4) 8 v2 = Vector2d((3, 4,)) 9 assert v1 == v2 10 11 12def test_vector_decomposition(): 13 x, y = Vector2d(21, 12) 14 assert x == 21 15 assert y == 12 16 17 18def test_rect(): 19 size = Vector2d(21, 12) 20 origin = Vector2d(2, 1) 21 rect = Rect2d(origin, size) 22 assert rect == Rect2d(2, 1, 21, 12) 23 assert rect.origin == Vector2d(2, 1) 24 assert rect.size == Vector2d(21, 12) 25 assert rect.right == 23 26 assert rect.bottom == 13 27 28 29def test_rect_decomposition(): 30 rect = Rect2d(2, 1, 21, 12) 31 x, y, w, h = rect 32 assert x == 2 33 assert y == 1 34 assert w == 21 35 assert h == 12 36 37 38def test_lerp(): 39 r = lerp(.5, 7.5, 8.0) 40 assert r == 7.75 41 with pytest.raises(ValueError): 42 r = lerp(.5, 2112, 2021)
def
test_vector():
def
test_vector_decomposition():
def
test_rect():
def
test_rect_decomposition():
def
test_lerp():