diff options
| author | gingerBill <bill@gingerbill.org> | 2021-10-11 20:05:13 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-10-11 20:05:13 +0100 |
| commit | b67e0002c19e60e3cfe8c67b22191be179bc4979 (patch) | |
| tree | 2b5c189c507d911cf77ee35f798e48e08a6e4ed5 /core/testing/testing.odin | |
| parent | 00701193926538084fa408a25b5932687973e18b (diff) | |
Add `testing.expect_value`; Improve `testing.set_fail_timeout`
Diffstat (limited to 'core/testing/testing.odin')
| -rw-r--r-- | core/testing/testing.odin | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin index 0f91c7020..63df26c1f 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -3,6 +3,7 @@ package testing import "core:fmt" import "core:io" import "core:time" +import "core:intrinsics" // IMPORTANT NOTE: Compiler requires this layout Test_Signature :: proc(^T) @@ -28,8 +29,6 @@ T :: struct { cleanups: [dynamic]Internal_Cleanup, _fail_now: proc() -> !, - _is_done: bool, - _fail_timeout_set: bool, } @@ -89,10 +88,17 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo } return ok } +expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> bool where intrinsics.type_is_comparable(T) { + ok := value == expected + if !ok { + errorf(t=t, format="expected %v, got %v", args={expected, value}, loc=loc) + } + return ok +} + set_fail_timeout :: proc(t: ^T, duration: time.Duration, loc := #caller_location) { - assert(t._fail_timeout_set == false, "set_fail_timeout previously called", loc) - t._fail_timeout_set = true + assert(global_fail_timeout_thread == nil, "set_fail_timeout previously called", loc) _fail_timeout(t, duration, loc) }
\ No newline at end of file |