Merge pull request #1299 from Kelimion/vendor-glfw-test

[vendor:glfw] Add test.
This commit is contained in:
Jeroen van Rijn
2021-11-10 19:24:55 +01:00
committed by GitHub
2 changed files with 51 additions and 1 deletions

View File

@@ -5,4 +5,9 @@ set PATH_TO_ODIN==..\..\odin
echo ---
echo Running vendor:botan tests
echo ---
%PATH_TO_ODIN% run botan %COMMON%
%PATH_TO_ODIN% run botan %COMMON%
echo ---
echo Running vendor:glfw tests
echo ---
%PATH_TO_ODIN% run glfw %COMMON%

45
tests/vendor/glfw/test_vendor_glfw.odin vendored Normal file
View File

@@ -0,0 +1,45 @@
package test_vendor_glfw
import "core:testing"
import "core:fmt"
import "vendor:glfw"
GLFW_MAJOR :: 3
GLFW_MINOR :: 3
GLFW_PATCH :: 4
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
fmt.printf("[%v] ", loc)
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.println(message)
return
}
fmt.println(" PASS")
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
main :: proc() {
t := testing.T{}
test_glfw(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
}
@(test)
test_glfw :: proc(t: ^testing.T) {
major, minor, patch := glfw.GetVersion()
expect(t, major == GLFW_MAJOR && minor == GLFW_MINOR, fmt.tprintf("Expected GLFW.GetVersion: %v.%v.%v, got %v.%v.%v instead", GLFW_MAJOR, GLFW_MINOR, GLFW_PATCH, major, minor, patch))
}