-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from labuzm/tests
initial setup for tests
- Loading branch information
Showing
8 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
cmake>=3.13.1 | ||
ninja==1.9.0.post1 | ||
Cython==0.29.21 | ||
scikit-build==0.11.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cmake>=3.13.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest==6.2.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import math | ||
|
||
import pytest | ||
|
||
from kaa.geometry import Vector | ||
|
||
|
||
def test_vector(): | ||
v1 = Vector.xy(1.) | ||
assert v1.x == 1. and v1.y == 1. | ||
v2 = Vector(2., 2.) | ||
assert v2.x == 2. and v2.y == 2. | ||
assert v1 == Vector(1., 1.) | ||
assert v2 == Vector(2., 2.) | ||
|
||
zero = Vector(0, 0) | ||
assert not zero | ||
assert zero.is_zero() | ||
|
||
assert v1 + v2 == Vector.xy(3) | ||
assert Vector.xy(3.) - v2 == v1 | ||
assert v1 * 10 == Vector.xy(10.) | ||
assert Vector.xy(10.) / 10 == v1 | ||
assert -v1 == Vector.xy(-1.) | ||
|
||
rotated_vector = Vector(1, 0).rotate_angle_degrees(90) | ||
assert pytest.approx(rotated_vector.x) == 0 | ||
assert pytest.approx(rotated_vector.y) == 1. | ||
|
||
v = Vector.from_angle_degrees(90) | ||
assert pytest.approx(rotated_vector.x) == 0 | ||
assert pytest.approx(rotated_vector.y) == 1. | ||
assert v.to_angle_degrees() == 90 | ||
assert Vector(1., 0).angle_between_degrees(Vector(0, 1.)) == 90 | ||
|
||
assert Vector(1., 0).normalize().dot(Vector(1, 1.).normalize()) > 0 | ||
assert Vector(1., 0).normalize().dot(Vector(0, 1.).normalize()) == 0 | ||
assert Vector(1., 0).normalize().dot(Vector(-1, 1.).normalize()) < 0 | ||
|
||
assert Vector(0, 0).distance(Vector(10., 0)) == 10. | ||
|
||
v = Vector(10., 10.) | ||
assert v.normalize() == v / v.length() | ||
assert v.length() == math.sqrt(v.x ** 2 + v.y ** 2) |