summaryrefslogtreecommitdiff
path: root/cesar/lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/lib/test')
-rw-r--r--cesar/lib/test/test/src/test_test.c56
1 files changed, 36 insertions, 20 deletions
diff --git a/cesar/lib/test/test/src/test_test.c b/cesar/lib/test/test/src/test_test.c
index 78409f8f5d..1f3ef9df94 100644
--- a/cesar/lib/test/test/src/test_test.c
+++ b/cesar/lib/test/test/src/test_test.c
@@ -14,11 +14,12 @@
#include "lib/test.h"
-void
-mytest_basic_test_case (test_t t)
+bool
+mytest_ok_test_case (test_t t)
{
- uint i;
- test_case_begin (t, "basic");
+ uint old_attempted = test_nb_attempted (t);
+ uint old_failed = test_nb_failed (t);
+ test_case_begin (t, "ok");
test_begin (t, "test no fail")
{
} test_end;
@@ -26,6 +27,29 @@ mytest_basic_test_case (test_t t)
{
test_fail_unless (1 == 1);
} test_end;
+ test_begin (t, "catch assert")
+ {
+ dbg_fatal_try_begin
+ {
+ dbg_assert (1 == 2);
+ }
+ dbg_fatal_try_catch (const char *the_error)
+ {
+ test_verbose_print ("catched: %s", the_error);
+ }
+ dbg_fatal_try_end;
+ } test_end;
+ return test_nb_attempted (t) == old_attempted + 3
+ && test_nb_failed (t) == old_failed + 0;
+}
+
+bool
+mytest_nok_test_case (test_t t)
+{
+ uint i;
+ uint old_attempted = test_nb_attempted (t);
+ uint old_failed = test_nb_failed (t);
+ test_case_begin (t, "nok");
test_begin (t, "test_fail_unless nok")
{
test_fail_unless (1 == 2);
@@ -43,18 +67,6 @@ mytest_basic_test_case (test_t t)
test_fail ("fail at i = %d", i);
}
} test_end;
- test_begin (t, "catch assert")
- {
- dbg_fatal_try_begin
- {
- dbg_assert (1 == 2);
- }
- dbg_fatal_try_catch (const char *the_error)
- {
- test_verbose_print ("catched: %s", the_error);
- }
- dbg_fatal_try_end;
- } test_end;
test_begin (t, "no catch assert")
{
dbg_assert (1 == 2);
@@ -70,13 +82,17 @@ mytest_basic_test_case (test_t t)
{
*(u32 *) NULL = 0;
} test_end;
+ return test_nb_attempted (t) == old_attempted + 6
+ && test_nb_failed (t) == old_failed + 6;
}
-void
+bool
mytest_test_suite (test_t t)
{
test_suite_begin (t, "mytest");
- mytest_basic_test_case (t);
+ bool success_ok = mytest_ok_test_case (t);
+ bool success_nok = mytest_nok_test_case (t);
+ return success_ok && success_nok;
}
int
@@ -84,7 +100,7 @@ main (int argc, char **argv)
{
test_t t;
test_init (t, argc, argv);
- mytest_test_suite (t);
+ bool success = mytest_test_suite (t);
test_result (t);
- return test_nb_failed (t) == 0 ? 0 : 1;
+ return success ? 0 : 1;
}