AtlatestRepositorysigil-raylib

sigil-raylib / tree / testtest-raylib.sgl

1;;; Raylib test suite
2;;; Tests data utilities and constants — no window/GPU required.
3
4(import (sigil core)
5 (sigil test)
6 (sigil ffi)
7 (raylib core)
8 (raylib input)
9 (raylib graphics))
11(test-group "raylib"
13 (test-group "Color helpers"
14 (test "make-color creates dict with RGBA fields" (fn ()
15 (let ((c (make-color 100 200 50 255)))
16 (assert-equal 100 (color-r c))
17 (assert-equal 200 (color-g c))
18 (assert-equal 50 (color-b c))
19 (assert-equal 255 (color-a c)))))
21 (test "predefined RED" (fn ()
22 (assert-equal 230 (color-r RED))
23 (assert-equal 41 (color-g RED))
24 (assert-equal 55 (color-b RED))
25 (assert-equal 255 (color-a RED))))
27 (test "predefined WHITE" (fn ()
28 (assert-equal 255 (color-r WHITE))
29 (assert-equal 255 (color-g WHITE))
30 (assert-equal 255 (color-b WHITE))
31 (assert-equal 255 (color-a WHITE))))
33 (test "predefined BLANK has zero alpha" (fn ()
34 (assert-equal 0 (color-a BLANK)))))
36 (test-group "Vector helpers"
37 (test "make-vec2" (fn ()
38 (let ((v (make-vec2 1.5 2.5)))
39 (assert-equal 1.5 (vec2-x v))
40 (assert-equal 2.5 (vec2-y v)))))
42 (test "make-vec3" (fn ()
43 (let ((v (make-vec3 1.0 2.0 3.0)))
44 (assert-equal 1.0 (vec3-x v))
45 (assert-equal 2.0 (vec3-y v))
46 (assert-equal 3.0 (vec3-z v)))))
48 (test "make-rect" (fn ()
49 (let ((r (make-rect 10.0 20.0 100.0 50.0)))
50 (assert-equal 10.0 (rect-x r))
51 (assert-equal 20.0 (rect-y r))
52 (assert-equal 100.0 (rect-width r))
53 (assert-equal 50.0 (rect-height r))))))
55 (test-group "Constants"
56 (test "keyboard keys are integers" (fn ()
57 (assert (integer? KEY_SPACE))
58 (assert (integer? KEY_ESCAPE))
59 (assert (integer? KEY_A))
60 (assert-equal 32 KEY_SPACE)
61 (assert-equal 256 KEY_ESCAPE)
62 (assert-equal 65 KEY_A)))
64 (test "mouse buttons are integers" (fn ()
65 (assert-equal 0 MOUSE_BUTTON_LEFT)
66 (assert-equal 1 MOUSE_BUTTON_RIGHT)
67 (assert-equal 2 MOUSE_BUTTON_MIDDLE)))
69 (test "config flags are powers of 2" (fn ()
70 (assert (integer? FLAG_VSYNC_HINT))
71 (assert (integer? FLAG_FULLSCREEN_MODE))
72 (assert (integer? FLAG_WINDOW_RESIZABLE))))
74 (test "log levels are ordered" (fn ()
75 (assert (< LOG_ALL LOG_TRACE))
76 (assert (< LOG_TRACE LOG_DEBUG))
77 (assert (< LOG_DEBUG LOG_INFO))
78 (assert (< LOG_INFO LOG_WARNING))
79 (assert (< LOG_WARNING LOG_ERROR))
80 (assert (< LOG_ERROR LOG_FATAL))
81 (assert (< LOG_FATAL LOG_NONE))))
83 (test "blend modes" (fn ()
84 (assert-equal 0 BLEND_ALPHA)
85 (assert-equal 1 BLEND_ADDITIVE)))
87 (test "camera modes" (fn ()
88 (assert-equal 0 CAMERA_CUSTOM)
89 (assert-equal 0 CAMERA_PERSPECTIVE)
90 (assert-equal 1 CAMERA_ORTHOGRAPHIC))))
92 (test-group "Struct layouts"
93 (test "color-layout is a valid layout" (fn ()
94 (assert (> (c-struct-size color-layout) 0))
95 (assert-equal 4 (c-struct-size color-layout))))
97 (test "vector2-layout size" (fn ()
98 (assert-equal 8 (c-struct-size vector2-layout))))
100 (test "vector3-layout size" (fn ()
101 (assert-equal 12 (c-struct-size vector3-layout))))
103 (test "rectangle-layout size" (fn ()
104 (assert-equal 16 (c-struct-size rectangle-layout)))))
106 (test-group "Library"
107 (test "rl-lib is a valid library handle" (fn ()
108 (assert (pointer? rl-lib))))))