diff options
| author | gitlost <burmartke@gmail.com> | 2022-03-08 18:06:25 +0000 |
|---|---|---|
| committer | gitlost <burmartke@gmail.com> | 2022-03-08 18:06:25 +0000 |
| commit | b94a7a87fabba83ecb7774f6a2d8a23c0075955a (patch) | |
| tree | dca81f1ec14cc7da382419e11fa8982a1595a99e /tests/common | |
| parent | 2b43387a9d8a1c50c4b7c10a504877afff9b7ebd (diff) | |
Fix issue #1574 "fract in linalg/glm is broken" by fixing
trunc_f16/32/64 in "math.odin" (~ typos on expressions)
Fix classify_f16 Inf test (would fail for subnormal 0h0001)
by changing multiplier 0.5 -> 0.25
Add some useful consts to "math.odin" (INF_F16 etc)
Add comment to "demo.odin" mentioning that -0.0 must be used
to specify negative zero
Diffstat (limited to 'tests/common')
| -rw-r--r-- | tests/common/common.odin | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/common/common.odin b/tests/common/common.odin new file mode 100644 index 000000000..2f5272b03 --- /dev/null +++ b/tests/common/common.odin @@ -0,0 +1,41 @@ +// Boilerplate for tests +package common + +import "core:testing" +import "core:fmt" +import "core:os" + +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) { + TEST_count += 1 + if !condition { + TEST_fail += 1 + fmt.printf("[%v] FAIL %s\n", loc, message) + return + } + fmt.printf("[%v] PASS\n", loc) + } + log :: proc(t: ^testing.T, v: any, loc := #caller_location) { + fmt.printf("[%v]", loc) + fmt.printf(" log: %v\n", v) + } +} + +report :: proc(t: ^testing.T) { + if TEST_fail > 0 { + if TEST_fail > 1 { + fmt.printf("%v/%v tests successful, %v tests failed.\n", TEST_count - TEST_fail, TEST_count, TEST_fail) + } else { + fmt.printf("%v/%v tests successful, %v test failed.\n", TEST_count - TEST_fail, TEST_count, TEST_fail) + } + os.exit(1) + } else { + fmt.printf("%v/%v tests successful.\n", TEST_count, TEST_count) + } +} |