Testing module

expect_equal

procedureextensionsince 0.28.0Source

got and want are compared by value: numbers of any width, strings, enums, arrays element by element (fixed, view and resizable alike) and structs member by member. Strings and arrays that differ get a diff.

Example
expect_equal(2 + 2, 4);
expect_equal("abc", "abc");
expect_equal(s32.[1, 2, 3], s32.[1, 2, 3]);
expect_equal(2 + 2, 4, "cut point 3"); // on failure, the message leads the difference
expect_equal :: (
    got: $T,
    want: $U,
    message := "",
    loc := #caller_location
) -> bool

got and want are compared by value: numbers of any width, strings, enums, arrays element by element (fixed, view and resizable alike) and structs member by member. Strings and arrays that differ get a diff.

Parameters

got: $T
the value under test.
want: $U
the value it must equal.
message := ""
what to say before the difference, such as which case of a loop failed.
loc := #caller_location
where the check is written, shown when it fails. Leave the default.

Returns

bool
Example
expect_equal(2 + 2, 4);
expect_equal("abc", "abc");
expect_equal(s32.[1, 2, 3], s32.[1, 2, 3]);
expect_equal(2 + 2, 4, "cut point 3"); // on failure, the message leads the difference

See also