From 99dcb2df6ee30004b9fbac1cc2360c6e627dc449 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 18 Dec 2016 21:31:43 -0800 Subject: Added support for test_reset(), better than cleanup or other hacks. --- tests/demo.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/demo.c') diff --git a/tests/demo.c b/tests/demo.c index 9ff70727..e831109a 100644 --- a/tests/demo.c +++ b/tests/demo.c @@ -62,4 +62,33 @@ test_main_group({ test_so(x == 1); }); }); + + test_group("Reset group", { + static int x = 0; + static int y = 0; + test_reset({ + x = 20; + }); + test_convey("Add one to both y and x", { + x++; + y++; + test_so(x == 1); /* no reset yet */ + test_so(y == 1); + }); + test_convey("Again", { + x++; + y++; + test_so(x == 21); + test_so(y == 2); + }); + test_convey("Third time", { + x++; + y++; + test_so(x == 21); + test_so(y == 3); + }); + + test_so(x == 20); + test_so(y == 3); + }); }) -- cgit v1.2.3-70-g09d2