-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_body_mirror.py
49 lines (37 loc) · 1.64 KB
/
test_body_mirror.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2023-2024 Andreas Kahler
# This file is part of Cadscript
# SPDX-License-Identifier: Apache-2.0
import unittest
import cadscript
from cadscript.interval import Interval3D
class BodyMirrorTest(unittest.TestCase):
def test_box_mirror_x(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("X")
self.assertEqual(box.get_extent(), Interval3D(-2, 2, 0, 2, 0, 2))
def test_box_mirror_y(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("Y")
self.assertEqual(box.get_extent(), Interval3D(0, 2, -2, 2, 0, 2))
def test_box_mirror_z(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("Z")
self.assertEqual(box.get_extent(), Interval3D(0, 2, 0, 2, -2, 2))
def test_box_mirror_x_no_copy(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("X", copy_and_merge=False)
self.assertEqual(box.get_extent(), Interval3D(-2, 0, 0, 2, 0, 2))
def test_box_mirror_y_no_copy(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("Y", copy_and_merge=False)
self.assertEqual(box.get_extent(), Interval3D(0, 2, -2, 0, 0, 2))
def test_box_mirror_z_no_copy(self):
box = cadscript.make_box(2, 2, 2, center=False)
box.mirror("Z", copy_and_merge=False)
self.assertEqual(box.get_extent(), Interval3D(0, 2, 0, 2, -2, 0))
def test_invalid_axis(self):
box = cadscript.make_box(2, 2, 2, center=False)
with self.assertRaises(ValueError):
box.mirror("A") # invalid axis
if __name__ == '__main__':
unittest.main()