Add control that all initialized testobj are properly cleared at the end of the test suite

This commit is contained in:
Patrick Pelissier committed 2023-03-12 20:29:58 +01:00
1 parent 2f57766249
commit d02de75487
16 files changed
+34 -8

No files matched your search

+1
View File
@@ -724,5 +724,6 @@ int main(void)
test_insert();
test_string_utf8();
test_fo();
testobj_final_check();
exit(0);
}
+1
View File
@@ -535,5 +535,6 @@ int main(void)
test_str();
test_double();
test_cplusplus();
testobj_final_check();
exit(0);
}
+1
View File
@@ -705,5 +705,6 @@ int main(void)
test_multiset();
test_double();
test_emplace();
testobj_final_check();
exit(0);
}
+1
View File
@@ -661,5 +661,6 @@ int main(void)
test_double1();
test_double2();
test_double3();
testobj_final_check();
exit(0);
}
+1
View File
@@ -947,5 +947,6 @@ int main(void)
test_M_CSTR();
test_properties();
test_generic_api();
testobj_final_check();
exit(0);
}
+1
View File
@@ -548,5 +548,6 @@ int main(void)
test_backward();
test_double();
test_remove();
testobj_final_check();
exit(0);
}
+1
View File
@@ -590,5 +590,6 @@ int main(void)
test_it_oa();
test_oa_str1();
test_oa_str2();
testobj_final_check();
exit(0);
}
+1 -1
View File
@@ -751,6 +751,6 @@ int main(void)
test_out_default_oplist();
test_double();
test_let_string();
testobj_final_check();
exit(0);
}
+1
View File
@@ -382,5 +382,6 @@ int main(void)
test_double();
test_it();
test_io();
testobj_final_check();
exit(0);
}
+1
View File
@@ -532,5 +532,6 @@ int main(void)
test_double();
test_from();
test_z();
testobj_final_check();
exit(0);
}
+1
View File
@@ -229,5 +229,6 @@ int main(void)
test_double();
test_double2();
test_double_res();
testobj_final_check();
exit(0);
}
+1 -1
View File
@@ -407,6 +407,6 @@ int main(void)
test_double();
test_doubleSPMC();
test_doubleMPMC();
testobj_final_check();
exit(0);
}
+6 -5
View File
@@ -527,9 +527,10 @@ static void test_emplace(void)
int main(void)
{
test_basic();
test_gen();
test_io();
test_emplace();
return 0;
test_basic();
test_gen();
test_io();
test_emplace();
testobj_final_check();
return 0;
}
+1
View File
@@ -288,5 +288,6 @@ int main(void)
check_reset();
check_chaining_tuple();
test_double();
testobj_final_check();
exit(0);
}
+1 -1
View File
@@ -297,6 +297,6 @@ int main(void)
test_triple();
test_io();
test_double();
testobj_final_check();
exit(0);
}
+14
View File
@@ -39,6 +39,14 @@ typedef struct testobj_s {
unsigned int *ptr;
} testobj_t[1];
int testobj_init_counter = 0;
static inline void testobj_final_check(void)
{
// All created testobj shall have been cleared at the end.
assert(testobj_init_counter == 0);
}
static inline void testobj_init(testobj_t z)
{
z->n = 1;
@@ -46,6 +54,7 @@ static inline void testobj_init(testobj_t z)
z->ptr = (unsigned int*) calloc(1, sizeof(unsigned int));
assert(z->ptr != NULL);
z->allocated = true;
testobj_init_counter++;
}
static inline void testobj_clear(testobj_t z)
@@ -55,6 +64,8 @@ static inline void testobj_clear(testobj_t z)
free(z->ptr);
z->ptr = NULL;
z->allocated = false;
testobj_init_counter--;
assert(testobj_init_counter >= 0);
}
static inline void testobj_init_set(testobj_t d, const testobj_t s)
@@ -65,6 +76,7 @@ static inline void testobj_init_set(testobj_t d, const testobj_t s)
assert(d->ptr != NULL);
memcpy(d->ptr, s->ptr, sizeof(unsigned int) * s->n);
d->allocated = true;
testobj_init_counter++;
}
static inline void testobj_set(testobj_t d, const testobj_t s)
@@ -178,6 +190,7 @@ static inline void testobj_str(string_t str, const testobj_t z, bool append)
PARSE_STR(testobj_parse_str), \
GET_STR(testobj_str), \
EQUAL(testobj_equal_p), \
INIT_WITH(testobj_init_set_ui), \
EMPLACE_TYPE( LIST( (_ui, testobj_init_set_ui, unsigned int), (_str, testobj_init_set_str, const char *), ( /*empty*/, testobj_init_set, testobj_t) ) ) \
)
@@ -193,6 +206,7 @@ static inline void testobj_str(string_t str, const testobj_t z, bool append)
GET_STR(testobj_str), \
EQUAL(testobj_equal_p), \
CMP(testobj_cmp), \
INIT_WITH(testobj_init_set_ui), \
EMPLACE_TYPE( LIST( (_ui, testobj_init_set_ui, unsigned int), (_str, testobj_init_set_str, const char *), ( /*empty*/, testobj_init_set, testobj_t) ) ) \
)