Update test suite
testing more functions in exception scenario
This commit is contained in:
1 parent
c245285123
commit
0914c26b8d
3 files changed
+71
-16
No files matched your search
+56
-4
@@ -31,6 +31,9 @@ M_TRY_DEF_ONCE()
|
||||
LIST_DEF(list_obj, test_obj_except__t, TEST_OBJ_EXCEPT_OPLIST)
|
||||
#define M_OPL_list_obj_t() LIST_OPLIST(list_obj, TEST_OBJ_EXCEPT_OPLIST)
|
||||
|
||||
LIST_DUAL_PUSH_DEF(list2_obj, test_obj_except__t, TEST_OBJ_EXCEPT_OPLIST)
|
||||
#define M_OPL_list2_obj_t() LIST_OPLIST(list2_obj, TEST_OBJ_EXCEPT_OPLIST)
|
||||
|
||||
static void test1(unsigned n)
|
||||
{
|
||||
FILE *f = m_core_fopen ("a-elist.dat", "wt");
|
||||
@@ -53,6 +56,8 @@ static void test1(unsigned n)
|
||||
bool b = list_obj_parse_str(list, string_get_cstr(str), NULL);
|
||||
assert(b);
|
||||
}
|
||||
list_obj_it_t it; list_obj_it(it, tmp); list_obj_next(it);
|
||||
list_obj_insert(tmp, it, obj);
|
||||
}
|
||||
} M_CATCH(test1, 0) {
|
||||
// Nothing to do
|
||||
@@ -70,19 +75,65 @@ static void test1(unsigned n)
|
||||
} M_CATCH(test1, 0) {
|
||||
// Nothing to do
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void do_test1(void)
|
||||
static void test2(unsigned n)
|
||||
{
|
||||
FILE *f = m_core_fopen ("a-elist.dat", "wt");
|
||||
assert(f != NULL);
|
||||
M_TRY(test1) {
|
||||
M_LET(obj, test_obj_except__t)
|
||||
M_LET(list, tmp, list2_obj_t) {
|
||||
for(unsigned i = 0; i < n; i++) {
|
||||
test_obj_except__set_ui(obj, i);
|
||||
list2_obj_push_back(list, obj);
|
||||
}
|
||||
list2_obj_set(tmp, list);
|
||||
M_LET( (tmp2, tmp), list2_obj_t) {
|
||||
list2_obj_out_str(f, tmp2);
|
||||
}
|
||||
list2_obj_push_back_new(tmp);
|
||||
list2_obj_splice(tmp, list);
|
||||
M_LET(str, string_t) {
|
||||
list2_obj_get_str(str, tmp, false);
|
||||
bool b = list2_obj_parse_str(list, string_get_cstr(str), NULL);
|
||||
assert(b);
|
||||
}
|
||||
list2_obj_it_t it; list2_obj_it(it, tmp); list2_obj_next(it);
|
||||
list2_obj_insert(tmp, it, obj);
|
||||
}
|
||||
} M_CATCH(test1, 0) {
|
||||
// Nothing to do
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
f = m_core_fopen ("a-elist.dat", "rt");
|
||||
assert(f != NULL);
|
||||
M_TRY(test1) {
|
||||
M_LET(obj, test_obj_except__t)
|
||||
M_LET(list, tmp, list2_obj_t) {
|
||||
bool b = list2_obj_in_str(list, f);
|
||||
(void)b;
|
||||
}
|
||||
} M_CATCH(test1, 0) {
|
||||
// Nothing to do
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void do_test1(void (*test)(unsigned))
|
||||
{
|
||||
// Run once to get the number of exceptions point existing in the test service
|
||||
test_obj_except__trigger_exception = 0;
|
||||
test1(10);
|
||||
test(10);
|
||||
test_obj_except__final_check();
|
||||
int count = -test_obj_except__trigger_exception;
|
||||
assert(count > 0);
|
||||
// Run once again the test service, and for each registered exception point, throw an exception
|
||||
for(int i = 1; i <= count; i++) {
|
||||
test_obj_except__trigger_exception = i;
|
||||
test1(10);
|
||||
test(10);
|
||||
// Check there is no memory leak
|
||||
test_obj_except__final_check();
|
||||
}
|
||||
@@ -90,6 +141,7 @@ static void do_test1(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1();
|
||||
do_test1(test1);
|
||||
//do_test1(test2);
|
||||
exit(0);
|
||||
}
|
||||
Reference in new issue
Block a user