aboutsummaryrefslogtreecommitdiff
path: root/core/testing/testing.odin
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-01-29 17:33:29 +0000
committerGitHub <noreply@github.com>2024-01-29 17:33:29 +0000
commit6736205723381d2344c07b143f8c4b3a39245069 (patch)
treea39d34d20f7e1bef36dc6532729253ec941b412b /core/testing/testing.odin
parentf0a7f1812f0884348f03f56bac7560bbb6eefbf8 (diff)
parent766d6aa94624b15192413d549f91427957b96f19 (diff)
Merge pull request #3138 from FourteenBrush/master
Add a testing.expectf proc as a way to avoid a tprintf call.
Diffstat (limited to 'core/testing/testing.odin')
-rw-r--r--core/testing/testing.odin11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin
index fa12c62b4..a8c5ffa48 100644
--- a/core/testing/testing.odin
+++ b/core/testing/testing.odin
@@ -80,7 +80,7 @@ logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) {
// cleanup registers a procedure and user_data, which will be called when the test, and all its subtests, complete
-// cleanup proceduers will be called in LIFO (last added, first called) order.
+// cleanup procedures will be called in LIFO (last added, first called) order.
cleanup :: proc(t: ^T, procedure: proc(rawptr), user_data: rawptr) {
append(&t.cleanups, Internal_Cleanup{procedure, user_data})
}
@@ -91,6 +91,14 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo
}
return ok
}
+
+expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool {
+ if !ok {
+ errorf(t, format, ..args, loc=loc)
+ }
+ return ok
+}
+
expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> bool where intrinsics.type_is_comparable(T) {
ok := value == expected || reflect.is_nil(value) && reflect.is_nil(expected)
if !ok {
@@ -100,7 +108,6 @@ expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> boo
}
-
set_fail_timeout :: proc(t: ^T, duration: time.Duration, loc := #caller_location) {
_fail_timeout(t, duration, loc)
}