]> git.jsancho.org Git - dungeon-master.git/blob - tests/bowyer-watson.scm
license
[dungeon-master.git] / tests / bowyer-watson.scm
1 ;;; Dungeon Master --- RPG Adventure Generator
2 ;;; Copyright © 2019 Javier Sancho <jsf@jsancho.org>
3 ;;;
4 ;;; Dungeon Master is free software; you can redistribute it and/or modify it
5 ;;; under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; Dungeon Master is distributed in the hope that it will be useful, but
10 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ;;; General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with Dungeon Master. If not, see <http://www.gnu.org/licenses/>.
16
17
18 (define-module (test-bowyer-watson)
19   #:use-module (ice-9 receive)
20   #:use-module (srfi srfi-64)
21   #:use-module (dungeon-master geom bowyer-watson)
22   #:use-module (dungeon-master geom point))
23
24 (test-begin "bowyer-watson")
25
26 (receive (triangles points frame)
27     (bowyer-watson '())
28   (test-equal
29    "null triangles"
30    (length triangles)
31    2)
32   (test-equal
33    "null points"
34    (length points)
35    4)
36   (test-equal
37    "null frame"
38    (length frame)
39    4))
40
41 (define p1 (make-point 0 0))
42 (define p2 (make-point 0 10))
43 (define p3 (make-point 10 0))
44 (define p4 (make-point 10 10))
45 (define vertices (list p1 p2 p3 p4))
46
47 (receive (triangles points frame)
48     (bowyer-watson vertices)
49   (test-equal
50    "simple triangles"
51    (length triangles)
52    10)
53   (test-equal
54    "simple points"
55    (length points)
56    8)
57   (test-equal
58    "simple frame"
59    frame
60    (list (make-point -2.5 -2.5)
61          (make-point -2.5 12.5)
62          (make-point 12.5 -2.5)
63          (make-point 12.5 12.5))))
64
65 (test-end)
66
67 (exit (zero? (test-runner-fail-count (test-runner-current))))