Changed all tests to use cr_-prefixed macros
This commit is contained in:
parent
58581f5b18
commit
2d46006201
10 changed files with 45 additions and 45 deletions
|
@ -1,54 +1,54 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(asserts, base) {
|
||||
assert(true);
|
||||
expect(true);
|
||||
cr_assert(true);
|
||||
cr_expect(true);
|
||||
|
||||
assert(true, "Assertions may take failure messages");
|
||||
cr_assert(true, "Assertions may take failure messages");
|
||||
|
||||
assert(true, .msg = "You can use explicit named arguments");
|
||||
cr_assert(true, .msg = "You can use explicit named arguments");
|
||||
|
||||
expect(false, "assert is fatal, expect isn't");
|
||||
assert(false, "This assert runs");
|
||||
assert(false, "This does not");
|
||||
cr_expect(false, "assert is fatal, expect isn't");
|
||||
cr_assert(false, "This assert runs");
|
||||
cr_assert(false, "This does not");
|
||||
}
|
||||
|
||||
Test(asserts, old_school) {
|
||||
if (false)
|
||||
abort_test("You can abort the test with a message from anywhere");
|
||||
cr_abort_test("You can abort the test with a message from anywhere");
|
||||
|
||||
abort_test(NULL); // or without a message
|
||||
cr_abort_test(NULL); // or without a message
|
||||
}
|
||||
|
||||
Test(asserts, string) {
|
||||
assert_strings_eq("hello", "hello");
|
||||
assert_strings_neq("hello", "olleh");
|
||||
cr_assert_strings_eq("hello", "hello");
|
||||
cr_assert_strings_neq("hello", "olleh");
|
||||
|
||||
assert_strings_gt("hello", "hell");
|
||||
assert_strings_geq("hello", "hell");
|
||||
assert_strings_geq("hello", "hello");
|
||||
cr_assert_strings_gt("hello", "hell");
|
||||
cr_assert_strings_geq("hello", "hell");
|
||||
cr_assert_strings_geq("hello", "hello");
|
||||
|
||||
assert_strings_lt("hell", "hello");
|
||||
assert_strings_leq("hell", "hello");
|
||||
assert_strings_leq("hello", "hello");
|
||||
cr_assert_strings_lt("hell", "hello");
|
||||
cr_assert_strings_leq("hell", "hello");
|
||||
cr_assert_strings_leq("hello", "hello");
|
||||
}
|
||||
|
||||
Test(asserts, native) {
|
||||
assert_eq(1, 1);
|
||||
assert_neq(1, 2);
|
||||
cr_assert_eq(1, 1);
|
||||
cr_assert_neq(1, 2);
|
||||
|
||||
assert_lt(1, 2);
|
||||
assert_leq(1, 2);
|
||||
assert_leq(2, 2);
|
||||
cr_assert_lt(1, 2);
|
||||
cr_assert_leq(1, 2);
|
||||
cr_assert_leq(2, 2);
|
||||
|
||||
assert_gt(2, 1);
|
||||
assert_geq(2, 1);
|
||||
assert_geq(2, 2);
|
||||
cr_assert_gt(2, 1);
|
||||
cr_assert_geq(2, 1);
|
||||
cr_assert_geq(2, 2);
|
||||
}
|
||||
|
||||
Test(asserts, float) {
|
||||
assert_neq(0.1 * 0.1, 0.01);
|
||||
assert_float_eq(0.1 * 0.1, 0.01, 0.001);
|
||||
cr_assert_neq(0.1 * 0.1, 0.01);
|
||||
cr_assert_float_eq(0.1 * 0.1, 0.01, 0.001);
|
||||
}
|
||||
|
||||
struct dummy_struct {
|
||||
|
@ -72,9 +72,9 @@ Test(asserts, array) {
|
|||
s2[1].a = 2;
|
||||
s2[1].b = 4;
|
||||
|
||||
assert_arrays_eq(arr1, arr1, 4);
|
||||
assert_arrays_neq(arr1, arr2, 4);
|
||||
cr_assert_arrays_eq(arr1, arr1, 4);
|
||||
cr_assert_arrays_neq(arr1, arr2, 4);
|
||||
|
||||
assert_arrays_neq(s1, s2, 2);
|
||||
assert_arrays_eq_cmp(s1, s2, 2, eq_dummy);
|
||||
cr_assert_arrays_neq(s1, s2, 2);
|
||||
cr_assert_arrays_eq_cmp(s1, s2, 2, eq_dummy);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(misc, failing, .description = "Just a failing test") {
|
||||
assert(0);
|
||||
cr_assert(0);
|
||||
}
|
||||
|
||||
Test(misc, skipped, .description = "This one is skipped", .disabled = true) {
|
||||
|
|
|
@ -10,5 +10,5 @@ void teardown(void) {
|
|||
}
|
||||
|
||||
Test(simple, fixtures, .init = setup, .fini = teardown) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(sample, long_msg) {
|
||||
assert(0, "This is\nA long message\nSpawning multiple lines.\n\nFormatting is respected.");
|
||||
cr_assert(0, "This is\nA long message\nSpawning multiple lines.\n\nFormatting is respected.");
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ void teardown_suite(void) {
|
|||
TestSuite(suite1, .init = setup_suite, .fini = teardown_suite);
|
||||
|
||||
Test(suite1, test) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
||||
Test(suite2, test) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
||||
TestSuite(disabled, .disabled = true);
|
||||
|
|
|
@ -6,9 +6,9 @@ void crash(void) {
|
|||
}
|
||||
|
||||
Test(misc, setup_crash, .init = crash) {
|
||||
assert(true);
|
||||
cr_assert(true);
|
||||
}
|
||||
|
||||
Test(misc, teardown_crash, .fini = crash) {
|
||||
assert(true);
|
||||
cr_assert(true);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(sample, test) {
|
||||
expect(0);
|
||||
assert(1);
|
||||
cr_expect(0);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
||||
ReportHook(PRE_INIT)(struct criterion_test *test) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(misc, failing) {
|
||||
assert(0);
|
||||
cr_assert(0);
|
||||
}
|
||||
|
||||
Test(misc, passing) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(first_suite, test) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
||||
Test(second_suite, test) {
|
||||
assert(1);
|
||||
cr_assert(1);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(samples, timed) {
|
||||
assert(0);
|
||||
cr_assert(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue