Transition to new testsuite
[nobug.git] / tests / test_nobug.c
blob205fbd28b00f8022c9f2296475b9c1e1e9fe60d1
1 #include "test.h"
2 #include "nobug.h"
4 struct foo
6 char b;
7 struct foo* bar;
8 };
10 void foo_invariant (struct foo* self, int depth, const char* file, int line, const char* func)
12 if (!depth) return;
14 INVARIANT_ASSERT(self->b != 8);
16 if (self->bar)
17 foo_invariant (self->bar, depth-1, file, line, func);
20 void nobug_foo_dump (const struct foo* self, const int depth, const char* file, const int line, const char* func)
22 if (self && depth)
24 DUMP_LOG("dump b is %d", self->b);
26 nobug_foo_dump (self->bar, depth-1, file, line, func);
30 NOBUG_DEFINE_FLAG(all);
31 NOBUG_DEFINE_FLAG_PARENT(test, all);
34 TESTS_BEGIN
36 int c = 0;
38 NOBUG_INIT_FLAG(test);
39 TRACE(test);
41 if (argc > 1)
42 c = atoi(argv[1]);
44 ECHO ("testing %d", c);
46 #if NOBUG_MODE_RELEASE == 0
47 UNCHECKED;
48 #endif
50 TEST(1)
52 REQUIRE (c != 1);
56 TEST(2)
58 REQUIRE (c != 2, "require %d failed", c);
61 TEST(3)
63 ENSURE(c != 3);
66 TEST(4)
68 ENSURE(c != 4, "ensure %d failed", c);
71 TEST(5)
73 ASSERT(c != 5);
76 TEST(6)
78 ASSERT(c != 6, "assert %d failed", c);
81 TEST(7)
83 CHECK(c != 7);
86 TEST(8)
88 struct foo f;
89 f.b = c;
90 f.bar = NULL;
92 INVARIANT(foo, &f, 2);
96 TEST(11)
98 struct foo f;
99 f.b = c;
100 f.bar = NULL;
102 DUMP(test, foo, &f, 2);
106 #if NOBUG_MODE_RELEASE == 0
107 TEST(13)
109 UNIMPLEMENTED("this is unimplemented");
111 #endif
113 TEST(14)
115 PLANNED("this is planned");
118 #if NOBUG_MODE_ALPHA == 1
119 TEST(15)
121 FIXME("here is a bug");
123 #endif
125 #if NOBUG_MODE_RELEASE == 0
126 TEST(16)
128 TODO("something todo");
130 #endif
132 TEST(17)
134 BACKTRACE;
137 TESTS_END