commit b01ca349ccb8138b903f6b6eb13d10d2e58626ca from: Sven M. Hallberg date: Mon May 26 11:35:06 2025 UTC test.h: rename check() macro to expect() I can't remember where else I've seen this naming, but I like it because it seems to match up more neatly with assert(). commit - 0f3b75642b06aadaae537f2f64929fdd9f77fae6 commit + b01ca349ccb8138b903f6b6eb13d10d2e58626ca blob - c816179663cfe2982283f6255ef8cdec5a87c160 blob + cfa012c47b8b25359fc53c80a74dea0d9160c297 --- lang/c/test.h +++ lang/c/test.h @@ -9,7 +9,7 @@ * * fail(fmt, ...); * - * check(expression); + * expect(expression); * * DESCRIPTION * The TEST() macro calls the given function as a unit test. Any @@ -28,9 +28,9 @@ * be called with an appropriate error message, using printf(3)-style * arguments. Any other diagnostics should be printed to stderr as usual. * - * The check() macro tests a boolean condition. It calls fail() if the + * The expect() macro tests a boolean condition. It calls fail() if the * given expression evaluates to false. The user should define custom - * variants of check() as suitable. + * variants of expect() as suitable. * * The fail() macro does not abort the current test unless the X * environment variable is set (see below). Checks that always form a @@ -55,13 +55,13 @@ * * void foo(void) * { - * check(1 == 1); + * expect(1 == 1); * } * * void bar(unsigned int mask) * { - * check(0x01 & mask != 0); - * check(0x10 & mask != 0); + * expect(0x01 & mask != 0); + * expect(0x10 & mask != 0); * } * * int main(int argc, char **argv) @@ -133,7 +133,7 @@ static int failed_; exit(1); \ } while (0) -#define check(EXP) do { \ +#define expect(EXP) do { \ if (!(EXP)) \ fail("condition failed: %s", #EXP); \ } while (0)