14 teardown(void *user_data
)
20 test_foo(void *user_data
)
22 int *data
= (int *)user_data
;
24 return (HARNESS_SKIP
);
28 return (HARNESS_FAIL
);
31 return (HARNESS_PASS
);
35 test_fail(void *user_data
)
38 return (HARNESS_FAIL
);
42 test_pass(void *user_data
)
45 return (HARNESS_PASS
);
49 test_long(void *user_data
)
53 return (HARNESS_PASS
);
57 test_assert_eq(void *user_data
)
63 return (HARNESS_PASS
);
67 test_assert_neq(void *user_data
)
73 return (HARNESS_PASS
);
77 test_assert_lt(void *user_data
)
83 return (HARNESS_PASS
);
87 test_assert_le(void *user_data
)
93 return (HARNESS_PASS
);
97 test_assert_gt(void *user_data
)
103 return (HARNESS_PASS
);
107 test_assert_ge(void *user_data
)
113 return (HARNESS_PASS
);
117 test_assert_streq(void *user_data
)
121 ASSERT_STREQ("foo", "bar");
123 return (HARNESS_PASS
);
127 test_assert_strne(void *user_data
)
131 ASSERT_STRNE("foo", "foo");
133 return (HARNESS_PASS
);
137 test_assert_double_eq(void *user_data
)
141 ASSERT_DOUBLE_EQ(95.1, 100.0, 0.01);
143 return (HARNESS_PASS
);
147 test_expect_eq(void *user_data
)
153 return (HARNESS_PASS
);
157 test_expect_neq(void *user_data
)
163 return (HARNESS_PASS
);
167 test_expect_lt(void *user_data
)
173 return (HARNESS_PASS
);
177 test_expect_le(void *user_data
)
183 return (HARNESS_PASS
);
187 test_expect_gt(void *user_data
)
193 return (HARNESS_PASS
);
197 test_expect_ge(void *user_data
)
203 return (HARNESS_PASS
);
207 test_expect_streq(void *user_data
)
211 EXPECT_STREQ("foo", "bar");
213 return (HARNESS_PASS
);
217 test_expect_strne(void *user_data
)
221 EXPECT_STRNE("foo", "foo");
223 return (HARNESS_PASS
);
227 test_expect_double_eq(void *user_data
)
231 EXPECT_DOUBLE_EQ(95.1, 100.0, 0.01);
233 return (HARNESS_PASS
);
237 main(int argc
, char *argv
[])
239 int ret
= EXIT_SUCCESS
;
242 struct harness_test tests
[] = {
243 {NULL
, NULL
, test_foo
, "test_foo", &argc
},
244 {NULL
, NULL
, NULL
, "", NULL
}
247 struct harness_cfg cfg
= {
249 .teardown
= teardown
,
253 if (harness_init(&cfg
) == 1) {
254 return (EXIT_FAILURE
);
257 harness_add_test("bar", "test_foo", test_foo
, NULL
, NULL
,
259 harness_add_test("bar", "test_fail", test_fail
, NULL
, NULL
, NULL
);
260 harness_add_test("baz", "test_foo", test_foo
, NULL
, NULL
,
262 harness_add_test("baz", "test_pass", test_pass
, NULL
, NULL
, NULL
);
263 harness_add_test("bar", "test_pass", test_pass
, NULL
, NULL
, NULL
);
264 harness_add_test("baz", "test_fail", test_fail
, NULL
, NULL
, NULL
);
265 harness_add_test("baz", "test_long", test_long
, NULL
, NULL
, NULL
);
266 harness_add_test("bar", "test_long", test_long
, NULL
, NULL
, NULL
);
268 harness_add_test("macro_assert_fail", "test_assert_eq",
269 test_assert_eq
, NULL
, NULL
, NULL
);
270 harness_add_test("macro_assert_fail", "test_assert_neq",
271 test_assert_neq
, NULL
, NULL
, NULL
);
272 harness_add_test("macro_assert_fail", "test_assert_lt",
273 test_assert_lt
, NULL
, NULL
, NULL
);
274 harness_add_test("macro_assert_fail", "test_assert_le",
275 test_assert_le
, NULL
, NULL
, NULL
);
276 harness_add_test("macro_assert_fail", "test_assert_gt",
277 test_assert_gt
, NULL
, NULL
, NULL
);
278 harness_add_test("macro_assert_fail", "test_assert_ge",
279 test_assert_ge
, NULL
, NULL
, NULL
);
280 harness_add_test("macro_assert_fail", "test_assert_streq",
281 test_assert_streq
, NULL
, NULL
, NULL
);
282 harness_add_test("macro_assert_fail", "test_assert_strne",
283 test_assert_strne
, NULL
, NULL
, NULL
);
284 harness_add_test("macro_assert_fail", "test_assert_double_eq",
285 test_assert_double_eq
, NULL
, NULL
, NULL
);
287 harness_add_test("macro_expect_fail", "test_expect_eq",
288 test_expect_eq
, NULL
, NULL
, NULL
);
289 harness_add_test("macro_expect_fail", "test_expect_neq",
290 test_expect_neq
, NULL
, NULL
, NULL
);
291 harness_add_test("macro_expect_fail", "test_expect_lt",
292 test_expect_lt
, NULL
, NULL
, NULL
);
293 harness_add_test("macro_expect_fail", "test_expect_le",
294 test_expect_le
, NULL
, NULL
, NULL
);
295 harness_add_test("macro_expect_fail", "test_expect_gt",
296 test_expect_gt
, NULL
, NULL
, NULL
);
297 harness_add_test("macro_expect_fail", "test_expect_ge",
298 test_expect_ge
, NULL
, NULL
, NULL
);
299 harness_add_test("macro_expect_fail", "test_expect_streq",
300 test_expect_streq
, NULL
, NULL
, NULL
);
301 harness_add_test("macro_expect_fail", "test_expect_strne",
302 test_expect_strne
, NULL
, NULL
, NULL
);
303 harness_add_test("macro_expect_fail", "test_expect_double_eq",
304 test_expect_double_eq
, NULL
, NULL
, NULL
);
306 harness_add_suite("example_suite", tests
);
307 harness_add_test("example_suite", "test_pass", test_pass
, NULL
, NULL
,
310 ret
= harness_run(NULL
);
311 harness_destroy(&cfg
);