Skip to content

Commit df5b4ab

Browse files
committed
add unit test
1 parent 4fb949c commit df5b4ab

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

TeXmacs/tests/23_27.scm

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
(import (liii check)
2+
(liii os))
3+
4+
; Because std-arc-helper is using define, it is not using tm-define
5+
; We have to load the module directly
6+
;
7+
; (texmacs-module (tests 23_27)
8+
; (:use (graphics graphics-markup)))
9+
(load (string-append (getenv "TEXMACS_PATH") "/progs/graphics/graphics-markup.scm"))
10+
11+
(define (point x y)
12+
(stree->tree `(point ,x ,y)))
13+
14+
(define (test-std-arc-helper)
15+
;c==p==q
16+
(check (std-arc-helper (point "0" "0") (point "0" "0") (point "0" "0") #f)
17+
=> `(arc (point "0" "0")
18+
(point "0" "0")
19+
(point "0" "0")))
20+
;c==p
21+
(check (std-arc-helper (point "0" "0") (point "0" "0") (point "1" "1") #f)
22+
=> `(arc (point "0" "0")
23+
(point "0" "0")
24+
(point "0" "0")))
25+
;c==q
26+
(check (std-arc-helper (point "0" "0") (point "1" "1") (point "0" "0") #f)
27+
=> `(arc (point "1" "1")
28+
(point "1" "1")
29+
(point "1" "1")))
30+
;p==q
31+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "1" "0") >)
32+
=> `(arc (point "1" "0")
33+
(point "1.0" "0.0")
34+
(point "1.0" "0.0")))
35+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "1" "0") <)
36+
=> `(arc (point "1" "0")
37+
(point "1.0" "0.0")
38+
(point "1.0" "0.0")))
39+
;cross-product==0, angle is 0 degree
40+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "2" "0") >)
41+
=> `(arc (point "1" "0")
42+
(point "1.0" "0.0")
43+
(point "1.0" "0.0")))
44+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "2" "0") <)
45+
=> `(arc (point "1" "0")
46+
(point "1.0" "0.0")
47+
(point "1.0" "0.0")))
48+
;cross-product==0, angle is 180 degree
49+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "-2" "0") >)
50+
=> `(arc (point "1" "0")
51+
(point "0.0" "-1.0")
52+
(point "-1.0" "0.0")))
53+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "-2" "0") <)
54+
=> `(arc (point "1" "0")
55+
(point "0.0" "1.0")
56+
(point "-1.0" "0.0")))
57+
;cross-product!=0
58+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "0" "1") >)
59+
=> `(arc (point "1" "0")
60+
(point "-0.7071067811865475" "-0.7071067811865475")
61+
(point "0.0" "1.0")))
62+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "0" "-1") >)
63+
=> `(arc (point "1" "0")
64+
(point "0.7071067811865475" "-0.7071067811865475")
65+
(point "0.0" "-1.0")))
66+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "0" "1") <)
67+
=> `(arc (point "1" "0")
68+
(point "0.7071067811865475" "0.7071067811865475")
69+
(point "0.0" "1.0")))
70+
(check (std-arc-helper (point "0" "0") (point "1" "0") (point "0" "-1") <)
71+
=> `(arc (point "1" "0")
72+
(point "-0.7071067811865475" "0.7071067811865475")
73+
(point "0.0" "-1.0"))))
74+
75+
(define (test_23_27)
76+
(test-std-arc-helper)
77+
(check-report)
78+
(if (check-failed?) (exit -1)))

0 commit comments

Comments
 (0)