Compares the printed form of value with its stored snapshot. Strings are compared as they
are; any other value is printed with one member or element to a line, so a change shows as
a line diff. A test that takes several snapshots numbers them, or names them with name.
Point :: struct { x, y: s32; }
prints_a_point :: (t: *Test) {
expect_snapshot(t, Point.{ 1, 2 });
expect_snapshot(t, "a block of text\nwith two lines", "text");
} @testThis one is only checked to compile, not run.
- t: the running test.
- value: what to snapshot.
- name: tells snapshots of one test apart; empty numbers them.
- loc: where the check is written, shown when it fails. Leave the default.
expect_snapshot :: (
t: *Test,
value: Any,
name := "",
loc := #caller_location
) -> bool
Compares the printed form of value with its stored snapshot. Strings are compared as they
are; any other value is printed with one member or element to a line, so a change shows as
a line diff. A test that takes several snapshots numbers them, or names them with name.
Parameters
- t: *Test
- the running test.
- value: Any
- what to snapshot.
- name := ""
- tells snapshots of one test apart; empty numbers them.
- loc := #caller_location
- where the check is written, shown when it fails. Leave the default.
Returns
- bool
Point :: struct { x, y: s32; }
prints_a_point :: (t: *Test) {
expect_snapshot(t, Point.{ 1, 2 });
expect_snapshot(t, "a block of text\nwith two lines", "text");
} @testThis one is only checked to compile, not run.
expect_snapshot :: (
t: *Test,
text: string,
name := "",
loc := #caller_location
) -> bool
expect_snapshot for text already in hand.
Parameters
- t: *Test
- the running test.
- text: string
- the text to compare, as it is.
- name := ""
- tells snapshots of one test apart; empty numbers them.
- loc := #caller_location
- where the check is written, shown when it fails. Leave the default.
Returns
- bool