From c213274607bca0b2d2d069d551470610ec136a50 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Wed, 10 Nov 2021 19:15:10 +0100 Subject: [PATCH] [vendor:glfw] Add test. --- tests/vendor/build.bat | 7 +++- tests/vendor/glfw/test_vendor_glfw.odin | 45 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/vendor/glfw/test_vendor_glfw.odin diff --git a/tests/vendor/build.bat b/tests/vendor/build.bat index 655883a5e..e70d9f1d5 100644 --- a/tests/vendor/build.bat +++ b/tests/vendor/build.bat @@ -5,4 +5,9 @@ set PATH_TO_ODIN==..\..\odin echo --- echo Running vendor:botan tests echo --- -%PATH_TO_ODIN% run botan %COMMON% \ No newline at end of file +%PATH_TO_ODIN% run botan %COMMON% + +echo --- +echo Running vendor:glfw tests +echo --- +%PATH_TO_ODIN% run glfw %COMMON% \ No newline at end of file diff --git a/tests/vendor/glfw/test_vendor_glfw.odin b/tests/vendor/glfw/test_vendor_glfw.odin new file mode 100644 index 000000000..252df2033 --- /dev/null +++ b/tests/vendor/glfw/test_vendor_glfw.odin @@ -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)) +} \ No newline at end of file