check_memory_pool.c
Go to the documentation of this file.
00001 
00002 #include <check.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <math.h>
00006 
00007 #include <memory_pool.h>
00008 
00009 #include "check_utils.h"
00010 
00011 memory_pool_t *test_pool_seq;
00012 memory_pool_t *test_pool_random;
00013 memory_pool_t *test_pool_empty;
00014 
00015 void setup()
00016 {
00017   /* Seed the random number generator with a specific seed for our test. */
00018   srandom(1);
00019 
00020   /* Create a new pool and fill it with a sequence of ints. */
00021   test_pool_seq = memory_pool_new(50, sizeof(s32));
00022 
00023   s32 *x;
00024   for (u32 i=0; i<22; i++) {
00025     x = (s32 *)memory_pool_add(test_pool_seq);
00026     fail_unless(x != 0, "Null pointer returned by memory_pool_add");
00027     *x = i;
00028   }
00029   /* Create a new pool and fill it entirely with random numbers. */
00030   test_pool_random = memory_pool_new(20, sizeof(s32));
00031 
00032   for (u32 i=0; i<20; i++) {
00033     x = (s32 *)memory_pool_add(test_pool_random);
00034     fail_unless(x != 0, "Null pointer returned by memory_pool_add");
00035     *x = sizerand(16);
00036   }
00037 
00038   /* Create a new pool and leave it empty. */
00039   test_pool_empty = memory_pool_new(50, sizeof(s32));
00040 }
00041 
00042 void teardown()
00043 {
00044   /* Test pools for leaks. */
00045   fail_unless(memory_pool_n_free(test_pool_seq)
00046               + memory_pool_n_allocated(test_pool_seq)
00047               == 50,
00048               "Memory leak! test_pool_seq lost elements!");
00049 
00050   fail_unless(memory_pool_n_free(test_pool_random)
00051               + memory_pool_n_allocated(test_pool_random)
00052               == 20,
00053               "Memory leak! test_pool_random lost elements!");
00054 
00055   fail_unless(memory_pool_n_free(test_pool_empty)
00056               + memory_pool_n_allocated(test_pool_empty)
00057               == 50,
00058               "Memory leak! test_pool_empty lost elements!");
00059 
00060   memory_pool_destroy(test_pool_seq);
00061   memory_pool_destroy(test_pool_random);
00062   memory_pool_destroy(test_pool_empty);
00063 }
00064 
00065 void print_s32(element_t *elem)
00066 {
00067   printf("%d ", *((s32 *)elem));
00068 }
00069 
00070 s32 isum(s32 x, element_t *elem)
00071 {
00072   s32 *y = (s32 *)elem;
00073   return x + *y;
00074 }
00075 
00076 double dsum(double x, element_t *elem)
00077 {
00078   s32 *y = (s32 *)elem;
00079   return x + *y;
00080 }
00081 
00082 float fsum(float x, element_t *elem)
00083 {
00084   s32 *y = (s32 *)elem;
00085   return x + *y;
00086 }
00087 
00088 START_TEST(test_simple_folds)
00089 {
00090   s32 sum;
00091 
00092   sum = memory_pool_ifold(test_pool_seq, 0, &isum);
00093   fail_unless(sum == 231,
00094       "Fold failed for isum function, expected 231, got %d", sum);
00095 
00096   sum = memory_pool_ifold(test_pool_seq, 22, &isum);
00097   fail_unless(sum == 253,
00098       "Fold failed for isum function, expected 253, got %d", sum);
00099 
00100   sum = (s32)memory_pool_dfold(test_pool_seq, 22, &dsum);
00101   fail_unless(sum == 253,
00102       "Fold failed for dsum function, expected 253, got %d", sum);
00103 
00104   sum = (s32)memory_pool_ffold(test_pool_seq, 22, &fsum);
00105   fail_unless(sum == 253,
00106       "Fold failed for fsum function, expected 253, got %d", sum);
00107 }
00108 END_TEST
00109 
00110 typedef struct {
00111   s32 min;
00112   s32 max;
00113 } min_max_t;
00114 
00115 void min_max_finder(void *x, element_t *elem)
00116 {
00117   s32 *y = (s32 *)elem;
00118   min_max_t *mm = (min_max_t *)x;
00119 
00120   if (*y > mm->max)
00121     mm->max = *y;
00122 
00123   if (*y < mm->min)
00124     mm->min = *y;
00125 }
00126 
00127 START_TEST(test_general_fold)
00128 {
00129   min_max_t mm = { .min = 1000, .max = -1000 };
00130   memory_pool_fold(test_pool_seq, &mm, &min_max_finder);
00131 
00132   fail_unless(mm.min == 0,
00133       "Fold failed for min_max_finder function, expected min 0, got %d", mm.min);
00134 
00135   fail_unless(mm.max == 21,
00136       "Fold failed for min_max_finder function, expected min 21, got %d", mm.max);
00137 }
00138 END_TEST
00139 
00140 START_TEST(test_full)
00141 {
00142   fail_unless(memory_pool_add(test_pool_random) == 0,
00143       "Adding to a full pool should return a NULL pointer.");
00144 }
00145 END_TEST
00146 
00147 START_TEST(test_n_free)
00148 {
00149   s32 n = memory_pool_n_free(test_pool_random);
00150   fail_unless(n == 0,
00151       "Error calculating free space in pool, expected 0, got %d", n);
00152 
00153   n = memory_pool_n_free(test_pool_seq);
00154   fail_unless(n == 28,
00155       "Error calculating free space in pool, expected 28, got %d", n);
00156 
00157   n = memory_pool_n_free(test_pool_empty);
00158   fail_unless(n == 50,
00159       "Error calculating free space in pool, expected 50, got %d", n);
00160 
00161   s32 i = 49;
00162   while(memory_pool_add(test_pool_empty)) {
00163     n = memory_pool_n_free(test_pool_empty);
00164     fail_unless(n == i,
00165         "Error calculating free space in pool, expected %d, got %d", i, n);
00166     i--;
00167   }
00168 }
00169 END_TEST
00170 
00171 START_TEST(test_n_allocated)
00172 {
00173   s32 n = memory_pool_n_allocated(test_pool_random);
00174   fail_unless(n == 20,
00175       "Error calculating free space in pool, expected 20, got %d", n);
00176 
00177   n = memory_pool_n_allocated(test_pool_seq);
00178   fail_unless(n == 22,
00179       "Error calculating free space in pool, expected 22, got %d", n);
00180 
00181   n = memory_pool_n_allocated(test_pool_empty);
00182   fail_unless(n == 0,
00183       "Error calculating free space in pool, expected 0, got %d", n);
00184 
00185   s32 i = 1;
00186   while(memory_pool_add(test_pool_empty)) {
00187     n = memory_pool_n_allocated(test_pool_empty);
00188     fail_unless(n == i,
00189         "Error calculating free space in pool, expected %d, got %d", i, n);
00190     i++;
00191   }
00192 }
00193 END_TEST
00194 
00195 START_TEST(test_empty)
00196 {
00197   fail_unless(!memory_pool_empty(test_pool_random),
00198       "Error checking if memory pool empty, should have been non-empty");
00199 
00200   fail_unless(memory_pool_empty(test_pool_empty),
00201       "Error checking if memory pool empty, should have been empty");
00202 }
00203 END_TEST
00204 
00205 START_TEST(test_pool_to_array)
00206 {
00207   s32 xs[22];
00208   s32 test_xs[22] = {
00209     21, 20, 19, 18, 17, 16, 15, 14, 13, 12,
00210     11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
00211   };
00212   memory_pool_to_array(test_pool_seq, xs);
00213 
00214   fail_unless(memcmp(xs, test_xs, sizeof(xs)) == 0,
00215       "Output of memory_pool_to_array does not match test data");
00216 }
00217 END_TEST
00218 
00219 void times_two(void *arg, element_t *elem)
00220 {
00221   (void) arg;
00222   s32 *x = (s32 *)elem;
00223   *x = *x * 2;
00224 }
00225 
00226 START_TEST(test_map)
00227 {
00228   s32 xs[22];
00229   s32 test_xs[22] = {
00230     42, 40, 38, 36, 34, 32, 30, 28, 26, 24,
00231     22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0
00232   };
00233 
00234   memory_pool_map(test_pool_seq, NULL, &times_two);
00235 
00236   memory_pool_to_array(test_pool_seq, xs);
00237   fail_unless(memcmp(xs, test_xs, sizeof(xs)) == 0,
00238       "Output of map operation does not match test data");
00239 }
00240 END_TEST
00241 
00242 s8 less_than_12(void *arg, element_t *elem)
00243 {
00244   (void) arg;
00245   return *((s32 *)elem) < 12;
00246 }
00247 
00248 START_TEST(test_filter_1)
00249 {
00250   s32 xs[22];
00251   s32 test_xs_beginning[12] = {
00252     11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
00253   };
00254 
00255   memory_pool_filter(test_pool_seq, NULL, &less_than_12);
00256   fail_unless(memory_pool_n_allocated(test_pool_seq) == 12,
00257       "Filtered length does not match");
00258 
00259   memory_pool_to_array(test_pool_seq, xs);
00260   fail_unless(memcmp(xs, test_xs_beginning, sizeof(test_xs_beginning)) == 0,
00261       "Output of filter operation does not match test data");
00262 }
00263 END_TEST
00264 
00265 s8 between_15_7(void *arg, element_t *elem)
00266 {
00267   (void) arg;
00268   return *((s32 *)elem) <= 15 && *((s32 *)elem) >= 7;
00269 }
00270 
00271 START_TEST(test_filter_2)
00272 {
00273   s32 xs[22];
00274   s32 test_xs_middle[9] = {
00275     15, 14, 13, 12, 11, 10, 9, 8, 7
00276   };
00277 
00278   memory_pool_filter(test_pool_seq, NULL, &between_15_7);
00279   fail_unless(memory_pool_n_allocated(test_pool_seq) == 9,
00280       "Filtered length does not match");
00281 
00282   memory_pool_to_array(test_pool_seq, xs);
00283   fail_unless(memcmp(xs, test_xs_middle, sizeof(test_xs_middle)) == 0,
00284       "Output of filter operation does not match test data");
00285 }
00286 END_TEST
00287 
00288 s8 greater_than_11(void *arg, element_t *elem)
00289 {
00290   (void) arg;
00291   return *((s32 *)elem) > 11;
00292 }
00293 
00294 START_TEST(test_filter_3)
00295 {
00296   s32 xs[22];
00297   s32 test_xs_end[10] = {
00298     21, 20, 19, 18, 17, 16, 15, 14, 13, 12
00299   };
00300 
00301   memory_pool_filter(test_pool_seq, NULL, &greater_than_11);
00302   fail_unless(memory_pool_n_allocated(test_pool_seq) == 10,
00303       "Filtered length does not match");
00304 
00305   memory_pool_to_array(test_pool_seq, xs);
00306   fail_unless(memcmp(xs, test_xs_end, sizeof(test_xs_end)) == 0,
00307       "Output of filter operation does not match test data");
00308 }
00309 END_TEST
00310 
00311 s8 even(void *arg, element_t *elem)
00312 {
00313   (void) arg;
00314   return *((s32 *)elem) % 2 == 0;
00315 }
00316 
00317 START_TEST(test_filter_4)
00318 {
00319   s32 xs[22];
00320   s32 test_xs_evens[11] = {
00321     20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0
00322   };
00323 
00324   memory_pool_filter(test_pool_seq, NULL, &even);
00325   fail_unless(memory_pool_n_allocated(test_pool_seq) == 11,
00326       "Filtered length does not match");
00327 
00328   memory_pool_to_array(test_pool_seq, xs);
00329   fail_unless(memcmp(xs, test_xs_evens, sizeof(test_xs_evens)) == 0,
00330       "Output of filter operation does not match test data");
00331 }
00332 END_TEST
00333 
00334 s32 cmp_s32s(void *arg, element_t *a_, element_t *b_)
00335 {
00336   (void)arg;
00337   s32 *a = (s32 *)a_;
00338   s32 *b = (s32 *)b_;
00339 
00340   return *a - *b;
00341 }
00342 
00343 START_TEST(test_clear)
00344 {
00345   memory_pool_clear(test_pool_seq);
00346   fail_unless(memory_pool_n_allocated(test_pool_seq) == 0,
00347       "Pool still not empty after clear");
00348 
00349   memory_pool_clear(test_pool_random);
00350   fail_unless(memory_pool_n_allocated(test_pool_random) == 0,
00351       "Pool still not empty after clear");
00352 
00353   memory_pool_clear(test_pool_empty);
00354   fail_unless(memory_pool_n_allocated(test_pool_empty) == 0,
00355       "Pool still not empty after clear");
00356 }
00357 END_TEST
00358 
00359 START_TEST(test_sort)
00360 {
00361   s32 xs[22];
00362   s32 test_xs_sorted[22] = {
00363     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00364     12, 13, 14, 15, 16, 17, 18, 19, 20, 21
00365   };
00366 
00367   memory_pool_sort(test_pool_seq, 0, &cmp_s32s);
00368   fail_unless(memory_pool_n_allocated(test_pool_seq) == 22,
00369       "Sorted length does not match");
00370 
00371   memory_pool_to_array(test_pool_seq, xs);
00372   fail_unless(memcmp(xs, test_xs_sorted, sizeof(test_xs_sorted)) == 0,
00373       "Output of sort operation does not match test data");
00374 
00375   s32 ys[20];
00376   s32 test_ys_sorted[20] = {
00377     3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11,
00378     11, 12, 13, 13, 13, 14, 15, 15, 16
00379   };
00380 
00381   memory_pool_sort(test_pool_random, 0, &cmp_s32s);
00382   fail_unless(memory_pool_n_allocated(test_pool_random) == 20,
00383       "Sorted length does not match");
00384 
00385   memory_pool_to_array(test_pool_random, ys);
00386   fail_unless(memcmp(ys, test_ys_sorted, sizeof(test_ys_sorted)) == 0,
00387       "Output of sort operation does not match test data");
00388 
00389   /* Test sorting an empty list. */
00390   memory_pool_sort(test_pool_empty, 0, &cmp_s32s);
00391   fail_unless(memory_pool_n_allocated(test_pool_empty) == 0,
00392       "Sorted length does not match");
00393   fail_unless(memory_pool_n_free(test_pool_empty) == 50,
00394       "Sorted length does not match");
00395 
00396   /* Test sorting a single element list. */
00397   s32 *x = (s32 *)memory_pool_add(test_pool_empty); *x = 22;
00398 
00399   memory_pool_sort(test_pool_empty, 0, &cmp_s32s);
00400   fail_unless(memory_pool_n_allocated(test_pool_empty) == 1,
00401       "Sorted length does not match");
00402   fail_unless(memory_pool_n_free(test_pool_empty) == 49,
00403       "Sorted length does not match");
00404 }
00405 END_TEST
00406 
00407 s32 group_evens(void *arg, element_t *a_, element_t *b_)
00408 {
00409   (void)arg;
00410   s32 *a = (s32 *)a_;
00411   s32 *b = (s32 *)b_;
00412 
00413   return (*a % 2) - (*b % 2);
00414 }
00415 
00416 void agg_sum_s32s(element_t *new_, void *x, u32 n, element_t *elem_)
00417 {
00418   (void)x;
00419 
00420   s32 *new = (s32 *)new_;
00421   s32 *elem = (s32 *)elem_;
00422 
00423   if (n == 0)
00424     *new = 0;
00425 
00426   *new += *elem;
00427 }
00428 
00429 START_TEST(test_groupby_1)
00430 {
00431   s32 xs[2];
00432   s32 test_xs_reduced[2] = {121, 110};
00433 
00434   memory_pool_group_by(test_pool_seq, 0, &group_evens, 0, 0, &agg_sum_s32s);
00435 
00436   fail_unless(memory_pool_n_allocated(test_pool_seq) == 2,
00437       "Reduced length does not match");
00438 
00439   memory_pool_to_array(test_pool_seq, xs);
00440   fail_unless(memcmp(xs, test_xs_reduced, sizeof(test_xs_reduced)) == 0,
00441       "Output of groupby operation does not match test data");
00442 
00443   /*memory_pool_map(test_pool_seq, &print_s32); printf("\n");*/
00444 }
00445 END_TEST
00446 
00447 typedef struct __attribute__((packed)) {
00448   float p;
00449   u8 len;
00450   u8 N[15];
00451 } hypothesis_t;
00452 
00453 void print_hyp_elem(element_t *hyp_)
00454 {
00455   hypothesis_t *hyp = (hypothesis_t *)hyp_;
00456   printf("[ ");
00457   for (u8 i=0; i<hyp->len; i++)
00458     printf("%d ", hyp->N[i]);
00459   printf("] %.3f\n", hyp->p);
00460 }
00461 
00462 s32 group_by_N_i(void *i_, element_t *a_, element_t *b_)
00463 {
00464   u8 *i = (u8 *)i_;
00465   hypothesis_t *a = (hypothesis_t *)a_;
00466   hypothesis_t *b = (hypothesis_t *)b_;
00467 
00468   for (u8 n=0; n<a->len; n++) {
00469     if (n == *i)
00470       continue;
00471     if (a->N[n] < b->N[n])
00472       return -1;
00473     if (a->N[n] > b->N[n])
00474       return 1;
00475   }
00476   return 0;
00477 }
00478 
00479 void agg_sum_p(element_t *new_, void *x_, u32 n, element_t *elem_)
00480 {
00481   u8 *x = (u8 *)x_;
00482   hypothesis_t *new = (hypothesis_t *)new_;
00483   hypothesis_t *elem = (hypothesis_t *)elem_;
00484 
00485   if (n == 0) {
00486     new->len = elem->len - 1;
00487     new->p = 0;
00488     u8 j=0;
00489     for (u8 i=0; i<elem->len; i++) {
00490       if (i != *x) {
00491         new->N[j] = elem->N[i];
00492         j++;
00493       }
00494     }
00495   }
00496   new->p += elem->p;
00497 }
00498 
00499 START_TEST(test_groupby_2)
00500 {
00501   /* Create a new pool. */
00502   memory_pool_t *test_pool_hyps = memory_pool_new(50, sizeof(hypothesis_t));
00503 
00504   for (u32 i=0; i<10; i++) {
00505     hypothesis_t *hyp = (hypothesis_t *)memory_pool_add(test_pool_hyps);
00506     fail_unless(hyp != 0, "Null pointer returned by memory_pool_add");
00507     hyp->len = 4;
00508     for (u8 j=0; j<hyp->len; j++) {
00509       hyp->N[j] = sizerand(2);
00510     }
00511     hyp->p = frand(0, 1);
00512   }
00513 
00514   u8 col = 1;
00515 
00516   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00517   /*memory_pool_sort(test_pool_hyps, &col, &group_by_N_i);*/
00518   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00519 
00520   memory_pool_group_by(test_pool_hyps, &col, &group_by_N_i,
00521                        &col, 1, &agg_sum_p);
00522 
00523   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00524 
00525   fail_unless(memory_pool_n_allocated(test_pool_hyps) == 7,
00526       "Reduced length does not match");
00527 
00528   hypothesis_t reduced_hyps[7];
00529   memory_pool_to_array(test_pool_hyps, reduced_hyps);
00530 
00531   for (u32 i=0; i<7; i++) {
00532     fail_unless(reduced_hyps[i].len == 3,
00533         "Output of groupby operation does not match test data");
00534     fail_unless(reduced_hyps[i].p >= 0 && reduced_hyps[i].p <= 2,
00535         "Output of groupby operation does not match test data, p not in range: %f",
00536         reduced_hyps[i].p);
00537   }
00538 
00539   fail_unless(fabs(reduced_hyps[5].p - 0.374936) < 0.00001,
00540       "Output of groupby operation does not match test data, p[5] = %f, expected 0.375",
00541       reduced_hyps[5].p);
00542 
00543   /* Test pool for leaks. */
00544   fail_unless(memory_pool_n_free(test_pool_hyps)
00545               + memory_pool_n_allocated(test_pool_hyps)
00546               == 50,
00547               "Memory leak! test_pool_hyps lost elements!");
00548 
00549   memory_pool_destroy(test_pool_hyps);
00550 }
00551 END_TEST
00552 
00553 void prod_N(element_t *new_, void *x_, u32 n_xs, u32 n, element_t *elem_)
00554 {
00555   (void)n;
00556   u8 *x = (u8 *)x_;
00557   hypothesis_t *new = (hypothesis_t *)new_;
00558   hypothesis_t *elem = (hypothesis_t *)elem_;
00559 
00560   new->len = elem->len + 1;
00561   new->p = elem->p / n_xs;
00562   new->N[new->len-1] = *x;
00563 }
00564 
00565 START_TEST(test_prod)
00566 {
00567   /* Create a new pool. */
00568   memory_pool_t *test_pool_hyps = memory_pool_new(50, sizeof(hypothesis_t));
00569 
00570   for (u32 i=0; i<3; i++) {
00571     hypothesis_t *hyp = (hypothesis_t *)memory_pool_add(test_pool_hyps);
00572     fail_unless(hyp != 0, "Null pointer returned by memory_pool_add");
00573     hyp->len = 4;
00574     for (u8 j=0; j<hyp->len; j++) {
00575       hyp->N[j] = sizerand(5);
00576     }
00577     hyp->p = frand(0, 1);
00578   }
00579 
00580   u8 new_N_vals[3] = {7, 8, 9};
00581 
00582   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00583 
00584   memory_pool_product(test_pool_hyps, new_N_vals, 3, sizeof(u8), &prod_N);
00585 
00586   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00587 
00588   fail_unless(memory_pool_n_allocated(test_pool_hyps) == 9,
00589       "Reduced length does not match");
00590 
00591   u8 col = 4;
00592   memory_pool_group_by(test_pool_hyps, &col, &group_by_N_i,
00593                        &col, 1, &agg_sum_p);
00594 
00595   fail_unless(memory_pool_n_allocated(test_pool_hyps) == 3,
00596       "Reduced length does not match");
00597 
00598   /*memory_pool_map(test_pool_hyps, &print_hyp_elem); printf("\n");*/
00599 
00600   memory_pool_destroy(test_pool_hyps);
00601 }
00602 END_TEST
00603 
00604 typedef struct {
00605   u8 val;
00606   u8 n_vals;
00607   u8 i;
00608 } test_gen_state_t;
00609 
00610 s8 test_next(void *x_, u32 n)
00611 {
00612   (void) n;
00613   test_gen_state_t *x = (test_gen_state_t *)x_;
00614   x->val = x->i * x->i;
00615   x->i++;
00616   if (x->i >= x->n_vals)
00617     return 0;
00618   return 1;
00619 }
00620 
00621 void prod_N_gen(element_t *new_, void *x_, u32 n, element_t *elem_)
00622 {
00623   (void)n;
00624   test_gen_state_t *x = (test_gen_state_t *)x_;
00625   hypothesis_t *new = (hypothesis_t *)new_;
00626   hypothesis_t *elem = (hypothesis_t *)elem_;
00627 
00628   new->len = elem->len + 1;
00629   new->N[new->len-1] = x->val;
00630 }
00631 
00632 START_TEST(test_prod_generator)
00633 {
00634   /* Create a new pool. */
00635   memory_pool_t *test_pool_hyps = memory_pool_new(50, sizeof(hypothesis_t));
00636 
00637   for (u32 i=0; i<3; i++) {
00638     hypothesis_t *hyp = (hypothesis_t *)memory_pool_add(test_pool_hyps);
00639     fail_unless(hyp != 0, "Null pointer returned by memory_pool_add");
00640     hyp->len = 4;
00641     for (u8 j=0; j<hyp->len; j++) {
00642       hyp->N[j] = sizerand(5);
00643     }
00644     hyp->p = frand(0, 1);
00645   }
00646 
00647   test_gen_state_t test_gen_state = {
00648     .val = 0,
00649     .n_vals = 3,
00650     .i = 0
00651   };
00652 
00653   memory_pool_product_generator(test_pool_hyps, &test_gen_state, 100, sizeof(test_gen_state_t), &test_next, &prod_N_gen);
00654 
00655   fail_unless(memory_pool_n_allocated(test_pool_hyps) == 9,
00656       "Reduced length does not match22");
00657 
00658   u8 col = 4;
00659   memory_pool_group_by(test_pool_hyps, &col, &group_by_N_i,
00660                        &col, 1, &agg_sum_p);
00661 
00662   fail_unless(memory_pool_n_allocated(test_pool_hyps) == 3,
00663       "Reduced length does not match33");
00664 
00665   memory_pool_destroy(test_pool_hyps);
00666 }
00667 END_TEST
00668 
00669 Suite* memory_pool_suite(void)
00670 {
00671   Suite *s = suite_create("Memory Pools");
00672 
00673   TCase *tc_core = tcase_create("Core");
00674   tcase_add_checked_fixture (tc_core, setup, teardown);
00675   tcase_add_test(tc_core, test_simple_folds);
00676   tcase_add_test(tc_core, test_general_fold);
00677   tcase_add_test(tc_core, test_full);
00678   tcase_add_test(tc_core, test_n_free);
00679   tcase_add_test(tc_core, test_n_allocated);
00680   tcase_add_test(tc_core, test_empty);
00681   tcase_add_test(tc_core, test_pool_to_array);
00682   tcase_add_test(tc_core, test_map);
00683   tcase_add_test(tc_core, test_filter_1);
00684   tcase_add_test(tc_core, test_filter_2);
00685   tcase_add_test(tc_core, test_filter_3);
00686   tcase_add_test(tc_core, test_filter_4);
00687   tcase_add_test(tc_core, test_clear);
00688   tcase_add_test(tc_core, test_sort);
00689   tcase_add_test(tc_core, test_groupby_1);
00690   tcase_add_test(tc_core, test_groupby_2);
00691   tcase_add_test(tc_core, test_prod);
00692   tcase_add_test(tc_core, test_prod_generator);
00693   suite_add_tcase(s, tc_core);
00694 
00695   return s;
00696 }
00697 


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:28