mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
Custom test runner.
This commit is contained in:
@@ -25,26 +25,39 @@ import "core:os"
|
||||
import "core:time"
|
||||
|
||||
import "core:runtime"
|
||||
import "core:io"
|
||||
|
||||
WRITE_PPM_ON_FAIL :: #config(WRITE_PPM_ON_FAIL, false)
|
||||
TEST_SUITE_PATH :: "assets/PNG"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
|
||||
when ODIN_TEST {
|
||||
expect :: testing.expect
|
||||
expect :: testing.expect
|
||||
log :: testing.log
|
||||
} else {
|
||||
expect :: proc(t: ^testing.T, condition: bool, message: string) {
|
||||
if !condition {
|
||||
fmt.println(message)
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
I_Error :: image.Error
|
||||
|
||||
main :: proc() {
|
||||
w, _ := io.to_writer(os.stream_from_handle(os.stdout))
|
||||
t := testing.T{w=w}
|
||||
t := testing.T{}
|
||||
png_test(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
}
|
||||
|
||||
PNG_Test :: struct {
|
||||
|
||||
Reference in New Issue
Block a user