Skip to content

Commit 2b5e9fd

Browse files
committed
add unit test
1 parent ec17687 commit 2b5e9fd

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

tests/compas/data/test_json.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import compas
2-
3-
from compas.geometry import Point, Vector, Frame
4-
from compas.geometry import Box
5-
from compas.geometry import Transformation
6-
7-
from compas.datastructures import Network
82
from compas.datastructures import Mesh
3+
from compas.datastructures import Network
94
from compas.datastructures import VolMesh
5+
from compas.geometry import Box
6+
from compas.geometry import Frame
7+
from compas.geometry import Point
8+
from compas.geometry import Transformation
9+
from compas.geometry import Vector
1010

1111

1212
def test_json_native():
@@ -15,20 +15,6 @@ def test_json_native():
1515
assert after == [[], [], {}, "", 1, 1.0, True, None]
1616

1717

18-
if not compas.IPY:
19-
import numpy as np
20-
21-
def test_json_numpy():
22-
before = [
23-
np.array([1, 2, 3]),
24-
np.array([1.0, 2.0, 3.0]),
25-
np.float64(1.0),
26-
np.int32(1),
27-
]
28-
after = compas.json_loads(compas.json_dumps(before))
29-
assert after == [[1, 2, 3], [1.0, 2.0, 3.0], 1.0, 1]
30-
31-
3218
def test_json_primitive():
3319
before = Point(0, 0, 0)
3420
after = compas.json_loads(compas.json_dumps(before))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import compas
2+
3+
try:
4+
import System
5+
6+
def test_decimal():
7+
before = System.Decimal(100.0)
8+
9+
after = compas.json_loads(compas.json_dumps(before))
10+
assert after == 100.0
11+
12+
except:
13+
pass
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import compas
2+
3+
try:
4+
import numpy as np
5+
6+
def test_json_numpy():
7+
before = [
8+
np.array([1, 2, 3]),
9+
np.array([1.0, 2.0, 3.0]),
10+
np.float64(1.0),
11+
np.int32(1),
12+
]
13+
after = compas.json_loads(compas.json_dumps(before))
14+
assert after == [[1, 2, 3], [1.0, 2.0, 3.0], 1.0, 1]
15+
16+
except:
17+
pass

0 commit comments

Comments
 (0)