Update test suite to properly allocation & deallocation

This commit is contained in:
Patrick Pelissier committed 2025-05-07 21:02:23 +02:00
1 parent 50e8d1f469
commit 37b2f4d2ac
29 files changed
+82 -68

No files matched your search

+1 -2
View File
@@ -20,6 +20,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "test-obj.h"
#include "m-list.h" #include "m-list.h"
#include "m-i-list.h" #include "m-i-list.h"
#include "m-array.h" #include "m-array.h"
@@ -29,8 +30,6 @@
#include "m-tuple.h" #include "m-tuple.h"
#include "m-algo.h" #include "m-algo.h"
#include "test-obj.h"
typedef struct over_s { typedef struct over_s {
unsigned long data; unsigned long data;
ILIST_INTERFACE(ilist_over, over_s); ILIST_INTERFACE(ilist_over, over_s);
+1 -2
View File
@@ -20,10 +20,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "coverage.h" #include "coverage.h"
#include "m-bitset.h" #include "m-bitset.h"
static void test1(void) static void test1(void)
+1 -3
View File
@@ -20,11 +20,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include <stdlib.h>
#include "m-string.h" #include "m-string.h"
#include "m-bptree.h" #include "m-bptree.h"
#include "test-obj.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
+1 -2
View File
@@ -20,9 +20,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "m-core.h" #include "test-obj.h"
#include "coverage.h" #include "coverage.h"
#include "m-bstring.h" #include "m-bstring.h"
static void test0(void) static void test0(void)
+2 -2
View File
@@ -20,10 +20,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "m-buffer.h"
#include "test-obj.h" #include "test-obj.h"
#include "m-buffer.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
// Define a fixed queue of unsigned int // Define a fixed queue of unsigned int
BUFFER_DEF(buffer_uint, unsigned int, 10, BUFFER_QUEUE|BUFFER_BLOCKING) BUFFER_DEF(buffer_uint, unsigned int, 10, BUFFER_QUEUE|BUFFER_BLOCKING)
+1 -1
View File
@@ -22,7 +22,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "coverage.h"
#include "m-array.h" #include "m-array.h"
#include "m-bptree.h" #include "m-bptree.h"
@@ -35,6 +34,7 @@
#include "m-variant.h" #include "m-variant.h"
#include "m-concurrent.h" #include "m-concurrent.h"
#include "coverage.h"
TUPLE_DEF2(point, (x, int), (y, int)) TUPLE_DEF2(point, (x, int), (y, int))
#define M_OPL_point_t() TUPLE_OPLIST(point, M_BASIC_OPLIST, M_BASIC_OPLIST) #define M_OPL_point_t() TUPLE_OPLIST(point, M_BASIC_OPLIST, M_BASIC_OPLIST)
+1 -2
View File
@@ -29,9 +29,8 @@
#define M_F(a,b) M_OVERRIDE_F(a,b) #define M_F(a,b) M_OVERRIDE_F(a,b)
#define M_OVERRIDE__method() , _get_method , #define M_OVERRIDE__method() , _get_method ,
#define M_OVERRIDE__method2() , _get_method2 #define M_OVERRIDE__method2() , _get_method2
#include "m-core.h"
#include "test-obj.h" #include "test-obj.h"
#include "m-core.h"
static bool tmp_init(void) { return true; } static bool tmp_init(void) { return true; }
static bool tmp_get_method(void) { return true; } static bool tmp_get_method(void) { return true; }
+3 -4
View File
@@ -21,17 +21,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdint.h> #include "test-obj.h"
#include <assert.h>
#include "m-dict.h" #include "m-dict.h"
#include "m-array.h" #include "m-array.h"
#include "m-string.h" #include "m-string.h"
#include "test-obj.h" #include "coverage.h"
static inline bool oor_equal_p(int k, unsigned char n) { return k == (int)-n-1; } static inline bool oor_equal_p(int k, unsigned char n) { return k == (int)-n-1; }
static inline void oor_set(int *k, unsigned char n) { *k = (int)-n-1; } static inline void oor_set(int *k, unsigned char n) { *k = (int)-n-1; }
static inline void update_value (int *p, const int p1, const int p2) { *p = p1 + p2; } static inline void update_value (int *p, const int p1, const int p2) { *p = p1 + p2; }
#include "coverage.h"
START_COVERAGE START_COVERAGE
DICT_DEF2(dict_str, string_t, STRING_OPLIST, string_t, STRING_OPLIST) DICT_DEF2(dict_str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_OA_DEF2(dict_oa_int, int, M_OPEXTEND(M_BASIC_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_OPEXTEND(M_BASIC_OPLIST, ADD(update_value M_IPTR))) DICT_OA_DEF2(dict_oa_int, int, M_OPEXTEND(M_BASIC_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_OPEXTEND(M_BASIC_OPLIST, ADD(update_value M_IPTR)))
-1
View File
@@ -20,7 +20,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-funcobj.h" #include "m-funcobj.h"
+2 -4
View File
@@ -21,14 +21,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdbool.h> #include "test-obj.h"
#include <assert.h>
#include "coverage.h"
#include "m-string.h" #include "m-string.h"
#include "m-array.h" #include "m-array.h"
#include "m-list.h" #include "m-list.h"
#include "m-generic.h" #include "m-generic.h"
#include "coverage.h"
// Generic is not supported if not C11 // Generic is not supported if not C11
// TCC has some issues in the preprocessing. // TCC has some issues in the preprocessing.
+1 -2
View File
@@ -20,12 +20,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include "m-thread.h" #include "m-thread.h"
#include "m-atomic.h" #include "m-atomic.h"
#include "m-core.h" #include "m-core.h"
#include "coverage.h" #include "coverage.h"
#include "m-genint.h" #include "m-genint.h"
#define MAX_N 256 #define MAX_N 256
+2 -3
View File
@@ -22,9 +22,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include "m-i-list.h" #include "m-i-list.h"
#include "coverage.h"
typedef struct test_s { typedef struct test_s {
int n; int n;
@@ -37,7 +37,6 @@ static inline bool test_equal_p(const test_t *i1, const test_t *i2)
return i1->n == i2->n; return i1->n == i2->n;
} }
#include "coverage.h"
START_COVERAGE START_COVERAGE
ILIST_DEF(ilist_tname, test_t, M_OPEXTEND(M_POD_OPLIST, EQUAL(API_6(test_equal_p)))) ILIST_DEF(ilist_tname, test_t, M_OPEXTEND(M_POD_OPLIST, EQUAL(API_6(test_equal_p))))
END_COVERAGE END_COVERAGE
-3
View File
@@ -20,11 +20,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <assert.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-i-shared.h" #include "m-i-shared.h"
#include "m-thread.h" #include "m-thread.h"
#include "coverage.h" #include "coverage.h"
+1 -2
View File
@@ -20,12 +20,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-list.h" #include "m-list.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
LIST_DEF(list_uint, unsigned int) LIST_DEF(list_uint, unsigned int)
LIST_DEF(list_mpz, testobj_t, TESTOBJ_OPLIST) LIST_DEF(list_mpz, testobj_t, TESTOBJ_OPLIST)
+2 -4
View File
@@ -21,12 +21,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include <stdlib.h>
#include "m-mempool.h" #include "m-mempool.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
MEMPOOL_DEF(mempool_uint, unsigned int) MEMPOOL_DEF(mempool_uint, unsigned int)
END_COVERAGE END_COVERAGE
+1 -3
View File
@@ -20,13 +20,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <assert.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-prioqueue.h" #include "m-prioqueue.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
PRIOQUEUE_DEF(int_pqueue, int) PRIOQUEUE_DEF(int_pqueue, int)
END_COVERAGE END_COVERAGE
+1 -2
View File
@@ -20,10 +20,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-rbtree.h" #include "m-rbtree.h"
#include "coverage.h"
static bool uint_in_str(unsigned int *u, FILE *f) static bool uint_in_str(unsigned int *u, FILE *f)
{ {
@@ -49,7 +49,6 @@ static void uint_get_str(string_t str, unsigned int u, bool append)
(append ? string_cat_printf : string_printf) (str, "%u", u); (append ? string_cat_printf : string_printf) (str, "%u", u);
} }
#include "coverage.h"
START_COVERAGE START_COVERAGE
RBTREE_DEF(rbtree_uint, unsigned int, M_OPEXTEND(M_BASIC_OPLIST, IN_STR(uint_in_str M_IPTR), OUT_STR(uint_out_str), GET_STR(uint_get_str), PARSE_STR(uint_parse_str M_IPTR)) ) RBTREE_DEF(rbtree_uint, unsigned int, M_OPEXTEND(M_BASIC_OPLIST, IN_STR(uint_in_str M_IPTR), OUT_STR(uint_out_str), GET_STR(uint_get_str), PARSE_STR(uint_parse_str M_IPTR)) )
END_COVERAGE END_COVERAGE
+1
View File
@@ -20,6 +20,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "test-obj.h"
#include "m-tuple.h" #include "m-tuple.h"
#include "m-array.h" #include "m-array.h"
#include "m-variant.h" #include "m-variant.h"
+1
View File
@@ -20,6 +20,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "test-obj.h"
#include "m-tuple.h" #include "m-tuple.h"
#include "m-array.h" #include "m-array.h"
#include "m-variant.h" #include "m-variant.h"
+1 -4
View File
@@ -20,10 +20,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include "test-obj.h"
#include "m-shared-ptr.h" #include "m-shared-ptr.h"
#include "m-string.h" #include "m-string.h"
#include "m-array.h" #include "m-array.h"
#include "m-bptree.h" #include "m-bptree.h"
@@ -34,7 +32,6 @@
#include "m-rbtree.h" #include "m-rbtree.h"
#include "m-tuple.h" #include "m-tuple.h"
#include "m-variant.h" #include "m-variant.h"
#include "coverage.h" #include "coverage.h"
// TEST WITH INT // TEST WITH INT
+1 -3
View File
@@ -20,12 +20,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <assert.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-shared.h" #include "m-shared.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
SHARED_PTR_DEF(shared_int, int) SHARED_PTR_DEF(shared_int, int)
SHARED_RESOURCE_DEF(shared_ressource, testobj_t, TESTOBJ_OPLIST) SHARED_RESOURCE_DEF(shared_ressource, testobj_t, TESTOBJ_OPLIST)
-2
View File
@@ -21,10 +21,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "test-obj.h" #include "test-obj.h"
#include "m-snapshot.h" #include "m-snapshot.h"
#include "m-thread.h" #include "m-thread.h"
#include "coverage.h" #include "coverage.h"
// Long Structure with a simple CRC to check for proper passing // Long Structure with a simple CRC to check for proper passing
+5 -4
View File
@@ -22,9 +22,8 @@
*/ */
#define M_USE_ADDITIONAL_CHECKS 1 #define M_USE_ADDITIONAL_CHECKS 1
#include "m-core.h" #include "test-obj.h"
#include "coverage.h" #include "coverage.h"
#include "m-string.h" #include "m-string.h"
BOUNDED_STRING_DEF(string16, 16) BOUNDED_STRING_DEF(string16, 16)
@@ -609,16 +608,18 @@ static void test0(void)
assert (string_equal_str_p(s1, "QWERTYQWERTY")); assert (string_equal_str_p(s1, "QWERTYQWERTY"));
string_clear (s2); string_clear (s2);
size_t cap = string_capacity(s1);
char *s = string_clear_get_str (s1); char *s = string_clear_get_str (s1);
assert(strcmp(s, "QWERTYQWERTY") == 0); assert(strcmp(s, "QWERTYQWERTY") == 0);
free(s); overloaded_free(1, s, cap <= sizeof (m_str1ng_heap_ct) - 1 ? strlen(s)+1 : cap );
string_t s3; string_t s3;
string_init(s3); string_init(s3);
string_cat_str(s3, "ABC"); string_cat_str(s3, "ABC");
cap = string_capacity(s3);
s = string_clear_get_str(s3); s = string_clear_get_str(s3);
assert(strcmp(s, "ABC") == 0); assert(strcmp(s, "ABC") == 0);
free(s); overloaded_free(1, s, cap <= sizeof (m_str1ng_heap_ct) - 1 ? strlen(s)+1 : cap );
string_init_set_str(s1, "RESTART"); string_init_set_str(s1, "RESTART");
assert (string_equal_str_p(s1, "RESTART")); assert (string_equal_str_p(s1, "RESTART"));
+1 -4
View File
@@ -20,11 +20,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "m-tree.h"
#include "test-obj.h" #include "test-obj.h"
#include "m-tree.h"
#include "m-string.h" #include "m-string.h"
#include "coverage.h" #include "coverage.h"
-1
View File
@@ -51,7 +51,6 @@ static bool test_final_in_progress;
#include "test-obj.h" #include "test-obj.h"
#include "coverage.h" #include "coverage.h"
#include "m-try.h" #include "m-try.h"
M_TRY_DEF_ONCE() M_TRY_DEF_ONCE()
+1 -3
View File
@@ -20,13 +20,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-tuple.h" #include "m-tuple.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
TUPLE_DEF2(pair, TUPLE_DEF2(pair,
(key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear))), (key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear))),
+1 -3
View File
@@ -20,13 +20,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "test-obj.h" #include "test-obj.h"
#include "m-string.h" #include "m-string.h"
#include "m-variant.h" #include "m-variant.h"
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
VARIANT_DEF2(pair, VARIANT_DEF2(pair,
(key, int, M_BASIC_OPLIST), (key, int, M_BASIC_OPLIST),
+1 -2
View File
@@ -20,9 +20,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "m-core.h" #include "test-obj.h"
#include "coverage.h" #include "coverage.h"
#include "m-worker.h" #include "m-worker.h"
/* Compute Fibonacci number using thread systems. */ /* Compute Fibonacci number using thread systems. */
+48
View File
@@ -25,6 +25,52 @@
#include <stdbool.h> #include <stdbool.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// First overwrite memory handling function so that we can check if everything is ok
#ifdef M_MEMORY_REALLOC
# error ERROR: Do not include M*LIB headers before this header.
#endif
static size_t amount_allocated = 0;
static inline void *overloaded_realloc(size_t st, void *ptr, size_t o, size_t n)
{
size_t *p = (size_t *) ptr;
if (p != NULL) {
p -= 2;
assert(p[0] == st);
assert(p[1] == o);
amount_allocated -= st * o;
}
p = (size_t *) realloc(p, 2*sizeof(size_t) + st * n);
assert(p != NULL);
p[0] = st;
p[1] = n;
amount_allocated += st * n;
return (void*) (&p[2]);
}
static inline void overloaded_free(size_t st, void *ptr, size_t n)
{
size_t *p = (size_t *) ptr;
if (p == NULL) {
return;
}
p -= 2;
assert(p[0] == st);
assert(p[1] == n);
amount_allocated -= st * n;
free(p);
}
#define M_MEMORY_REALLOC(type, ptr, o, n) (type *) overloaded_realloc(sizeof(type), ptr, o, n)
#define M_MEMORY_FREE(type, ptr, o) overloaded_free(sizeof(type), ptr, o)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "m-string.h" #include "m-string.h"
@@ -45,6 +91,8 @@ static inline void testobj_final_check(void)
{ {
// All created testobj shall have been cleared at the end. // All created testobj shall have been cleared at the end.
assert(testobj_init_counter == 0); assert(testobj_init_counter == 0);
// All memory allocations shall be cleared
assert(amount_allocated == 0);
} }
static inline void testobj_init(testobj_t z) static inline void testobj_init(testobj_t z)