Skip to content

Commit f68d0ea

Browse files
committed
some unittests
1 parent 74ed836 commit f68d0ea

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
from compas.geometry import Capsule
4+
5+
6+
@pytest.fixture
7+
def capsule():
8+
return Capsule(123.0, 13.0)
9+
10+
11+
def test_capsule_discretization(capsule):
12+
# just checking these don't break. Could not quickly find a formula that worked to test the actual values
13+
# as function of the resolution
14+
assert capsule.edges
15+
assert capsule.faces
16+
assert capsule.vertices

tests/compas/geometry/test_cone.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
from compas.geometry import Cone
4+
5+
6+
@pytest.fixture
7+
def cone():
8+
return Cone(432.0, 123.0)
9+
10+
11+
def test_cone_discretization(cone):
12+
# just checking these don't break. Could not quickly find a formula that worked to test the actual values
13+
# as function of the resolution
14+
assert cone.edges
15+
assert cone.faces
16+
assert cone.vertices
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
from compas.geometry import Cylinder
3+
4+
5+
@pytest.fixture
6+
def cylinder():
7+
return Cylinder(radius=0.3, height=1.6)
8+
9+
10+
def test_cylinder_discretization(cylinder):
11+
# just checking these don't break. Could not quickly find a formula that worked to test the actual values
12+
# as function of the resolution
13+
assert cylinder.edges
14+
assert cylinder.faces
15+
assert cylinder.vertices

tests/compas/geometry/test_shpere.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def sphere():
1010

1111

1212
def test_sphere_discretization(sphere):
13-
assert len(sphere.edges) == 496
14-
assert len(sphere.faces) == 256
15-
assert len(sphere.vertices) == 242
13+
expected_face_count = sphere.resolution_v * sphere.resolution_u
14+
expected_vertex_count = (sphere.resolution_v - 1) * sphere.resolution_u + 2
15+
expected_edge_count = expected_face_count * 2 - sphere.resolution_u
16+
17+
assert len(sphere.edges) == expected_edge_count
18+
assert len(sphere.faces) == expected_face_count
19+
assert len(sphere.vertices) == expected_vertex_count

0 commit comments

Comments
 (0)