Factorize common test function
This commit is contained in:
1 parent
9d33c85e13
commit
d466e76702
3 files changed
+18
-35
No files matched your search
+1
-18
@@ -81,25 +81,8 @@ static void test1(unsigned n)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void do_test1(void)
|
||||
{
|
||||
// Run once to get the number of exceptions point existing in the test service
|
||||
test_obj_except__trigger_exception = 0;
|
||||
test1(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);
|
||||
// Check there is no memory leak
|
||||
test_obj_except__final_check();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1();
|
||||
do_test1(test1);
|
||||
exit(0);
|
||||
}
|
||||
@@ -138,23 +138,6 @@ static void test3(unsigned n)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
test(10);
|
||||
// Check there is no memory leak
|
||||
test_obj_except__final_check();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1(test1);
|
||||
|
||||
@@ -231,6 +231,23 @@ static inline void test_obj_except__str(string_t str, const test_obj_except__t z
|
||||
|
||||
#define M_OPL_test_obj_except__t() TEST_OBJ_EXCEPT_OPLIST
|
||||
|
||||
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;
|
||||
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;
|
||||
test(10);
|
||||
// Check there is no memory leak
|
||||
test_obj_except__final_check();
|
||||
}
|
||||
}
|
||||
|
||||
M_END_PROTECTED_CODE
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user