Add new macros to define container
with the full given name.
This commit is contained in:
1 parent
1d8e541205
commit
7f26ef0f1c
6 files changed
+96
-2
No files matched your search
@@ -31,6 +31,8 @@ START_COVERAGE
|
||||
MEMPOOL_DEF(mempool_uint, unsigned int)
|
||||
END_COVERAGE
|
||||
|
||||
MEMPOOL_DEF_AS(MempoolDouble, MempoolDouble, unsigned int)
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mempool_uint_t m;
|
||||
@@ -65,8 +67,43 @@ static void test(void)
|
||||
mempool_uint_clear(m);
|
||||
}
|
||||
|
||||
static void test_double(void)
|
||||
{
|
||||
MempoolDouble m;
|
||||
MempoolDouble_init(m);
|
||||
|
||||
unsigned int *tab[100000];
|
||||
for(unsigned int i = 0; i < 100000; i++) {
|
||||
tab[i] = MempoolDouble_alloc(m);
|
||||
*tab[i] = i;
|
||||
}
|
||||
for(unsigned int i = 0; i < 100000; i++) {
|
||||
assert (*tab[i] == i);
|
||||
}
|
||||
for(unsigned int i = 0; i < 100000; i+=2) {
|
||||
MempoolDouble_free(m, tab[i]);
|
||||
tab[i] = NULL;
|
||||
}
|
||||
for(unsigned int i = 1; i < 100000; i+=2) {
|
||||
assert (*tab[i] == i);
|
||||
}
|
||||
for(unsigned int i = 0; i < 100000; i+=2) {
|
||||
tab[i] = MempoolDouble_alloc(m);
|
||||
*tab[i] = i;
|
||||
}
|
||||
for(unsigned int i = 0; i < 100000; i++) {
|
||||
assert (*tab[i] == i);
|
||||
}
|
||||
for(unsigned int i = 0; i < 100000; i++) {
|
||||
MempoolDouble_free(m, tab[i]);
|
||||
tab[i] = NULL;
|
||||
}
|
||||
MempoolDouble_clear(m);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test();
|
||||
test_double();
|
||||
exit(0);
|
||||
}
|
||||
@@ -31,6 +31,9 @@ PRIOQUEUE_DEF(int_pqueue, int)
|
||||
END_COVERAGE
|
||||
PRIOQUEUE_DEF(mpz_pqueue, testobj_t, TESTOBJ_CMP_OPLIST)
|
||||
|
||||
PRIOQUEUE_DEF_AS(PrioDouble, PrioDouble, PrioDoubleIt, double)
|
||||
#define M_OPL_PrioDouble() PRIOQUEUE_OPLIST(PrioDouble, M_DEFAULT_OPLIST)
|
||||
|
||||
static void test1(void)
|
||||
{
|
||||
int x;
|
||||
@@ -101,9 +104,22 @@ static void test2(void)
|
||||
int_pqueue_clear(p);
|
||||
}
|
||||
|
||||
static void test_double(void)
|
||||
{
|
||||
M_LET( (tab, 0.0, 1.0, 2.0, 3.0), PrioDouble) {
|
||||
double ref = 0.0;
|
||||
// NOTE: The binary heap is sorted in the same natural order that the sorted array
|
||||
for M_EACH(i, tab, PrioDouble) {
|
||||
assert (*i == ref);
|
||||
ref += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test_double();
|
||||
exit(0);
|
||||
}
|
||||
Reference in new issue
Block a user