Esempio n. 1
0
void mu_test_sort()
{
    my_t n1 = {{{2}, {3}}, 1};
    my_t n2 = {{{10}, {6}}, 2};
    my_t n3 = {{{11}, {34}}, 2};
    my_t n4 = {{{1}, {33}}, 3};

    list_t list;
    list_init(&list);

    // 2 ->  1 -> 3 -> 2
    list_push_back(&n2.link, &list);
    list_push_back(&n1.link, &list);
    list_push_back(&n4.link, &list);
    list_push_back(&n3.link, &list);

    mu_check(list_front(&list) == &n2.link);
    mu_check(list_next(&n2.link) == &n1.link);
    mu_check(list_next(&n1.link) == &n4.link);
    mu_check(list_next(&n4.link) == &n3.link);
    mu_check(list_back(&list) == &n3.link);

    puts("pre sort:");
    print(list_first(&n1.link));

    list_sort(&list, my_cmp);
    mu_check(list_front(&list) == &n1.link);
    mu_check(list_next(&n1.link) == &n2.link);
    mu_check(list_next(&n2.link) == &n3.link);
    mu_check(list_next(&n3.link) == &n4.link);
    mu_check(list_back(&list) == &n4.link);

    puts("post sort:");
    print(list_first(&n1.link));
}
inline void check_bitbuffer_invariants(bitbuffer b) {
    // check the position in the buffer plus the remaining bytes
    // is the end of the buffer
    mu_check(b.buffer_origin + (b.buflen_max - b.remaining_bytes) == b.buffer);

    // check that the head_offset is between 0 and 7
    mu_check(b.head_offset >= 0);
    mu_check(b.head_offset <= 7);
}
Esempio n. 3
0
int test_crossover_config_new_and_destroy(void)
{
    float uninit = -1.0f;
    struct crossover_config *cc = crossover_config_new(0);

    mu_check(cc->method == 0);
    mu_check(fltcmp(&cc->probability, &uninit) == 0);

    crossover_config_destroy(cc);
    return 0;
}
Esempio n. 4
0
int test_stack_new_and_destroy(void)
{
    struct stack *s = stack_new();

    mu_check(s->size == 0);
    mu_check(s->root == NULL);
    mu_check(s->end == NULL);

    stack_destroy(s, free);
    return 0;
}
void mu_test_bitbuffer_init_free_heap() {
    size_t size = sizeof(char) * 100;
    bitbuffer b;

    bitbuffer_init(&b, size);

    mu_check(b.buflen_max == size);
    check_bitbuffer_invariants(b);
    mu_check(b.buffer_controlled);

    bitbuffer_free(&b);
}
void mu_test_bitbuffer_init_free_stack() {
    size_t size = sizeof(char) * 100;
    char buff[size];
    bitbuffer b;
    bitbuffer_init_from_buffer(&b, buff, size);

    mu_check(b.buflen_max == size);
    mu_check(b.buffer == buff);
    mu_check(!b.buffer_controlled);
    check_bitbuffer_invariants(b);

    bitbuffer_free(&b);
}
Esempio n. 7
0
void mu_test_sml_queue()
{
	sml_queue_t head;
	sml_queue_init(&head);
	sml_queue_t *q;
	for(int i=0; i < 40; i++) {
		node *val= (node *)malloc(sizeof(node));
		val->data = i;
		if(i & 1) {
			sml_queue_insert_tail(&head, &(val->q));
		}
		else {
			sml_queue_insert_head(&head, &(val->q));
		}
	}
	q = sml_queue_first(&head);
	int j = 38, k = 1;
	while(q != sml_queue_head(&head)) {
		node *val = sml_queue_data(q, node, q);
		mu_check(val->data == j);
		//printf("%d ", val->data);
		if(j == 0) break;
		j -= 2;
		q = sml_queue_next(q);
	}
	q = sml_queue_next(q);
	while(q != sml_queue_head(&head)) {
		node *val = sml_queue_data(q, node, q);
		mu_check(val->data == k);
		//printf("%d ", val->data);
		k += 2;
		q = sml_queue_next(q);
	}
	sml_queue_sort(&head, cmp);
	q = sml_queue_first(&head);
	j = 0;
	while(q != sml_queue_head(&head)) {
		node *val = sml_queue_data(q, node, q);
		mu_check(val->data == j);
		j++;
		//printf("%d ", val->data);
		q = sml_queue_next(q);
	}
	q = sml_queue_first(&head);
	while(q != sml_queue_head(&head)) {
		node *val = sml_queue_data(q, node, q);
		free(val);
		q = sml_queue_next(q);
	}
}
Esempio n. 8
0
int test_crossover_config_new_and_destroy(void)
{
    float uninit = -1.0f;
    struct crossover_config *cc;

    /* setup */
    cc = crossover_config_new();

    /* assert */
    mu_check(cc->methods == NULL);
    mu_check(fltcmp(cc->probability, uninit) == 0);

    /* clean up */
    crossover_config_destroy(cc);

    return 0;
}
void mu_test_bitbuffer_advance_sequential() {
    size_t numchars = 10;
    bitbuffer b;
    for (size_t step = 1; step < numchars; step++) {
        bitbuffer_init(&b, sizeof(char) * numchars);

        int i;
        for (i = 0; i < (int)numchars; i += step) {
            mu_check(b.buffer - b.buffer_origin == i / 8);
            bitbuffer_advance(&b, step);
            check_bitbuffer_invariants(b);
        }
        mu_check(b.buffer - b.buffer_origin == i / 8);

        bitbuffer_free(&b);
    }
}
Esempio n. 10
0
int test_regression_evaluate(void)
{
    int i;
    int res;
    float f = 100.0;
    float **func_input;
    float solution_score = 5.0;
    struct tree *t;
    struct node **chromosome = malloc(sizeof(struct node *) * 5);
    struct data *d = csv_load_data(TEST_DATA, 1, ",");

    /* initialize func_input */
    func_input = malloc(sizeof(float *) * 2);
    for (i = 0; i < 2; i++) {
        func_input[i] = malloc(sizeof(float) * (unsigned long) d->rows);
    }

    /* build chromosome */
    chromosome[0] = node_new_constant(FLOAT, &f);
    chromosome[1] = node_new_input((char *) "x");
    chromosome[2] = node_new_func(MUL, 2);
    chromosome[3] = node_new_func(RAD, 1);
    chromosome[4] = node_new_func(SIN, 1);

    /* build tree */
    t = malloc(sizeof(struct tree));
    t->root = NULL;
    t->size = 5;
    t->depth = -1;
    t->score = NULL;
    t->chromosome = chromosome;

    /* evaluate tree */
    res = regression_evaluate(t, func_input, d, (char *) "y");
    mu_check(res == 0);
    mu_check(fltcmp(t->score,  &solution_score) == 0);
    mu_check(t->hits == 361);

    /* clean up */
    free_chromosome(chromosome, 5);
    tree_destroy(t);
    data_destroy(d);
    free_mem_arr(func_input, 2, free);
    return 0;
}
Esempio n. 11
0
void mu_test_sml_random_combined() {
    sml_combined_random_init((unsigned int)time(NULL));
    int cas = 30, n = 2000;

    while(cas--) {
        double v = x2cal(n, sml_combined_random_int);
        mu_check(v < 15.09 && v > 0.5543);
        n += 2000;
    }
}
Esempio n. 12
0
int test_function_max_arity(void)
{
    int max_arity;

    setup_function_set();
    max_arity = function_max_arity(fs);
    mu_check(max_arity == 2);
    teardown_function_set();

    return 0;
}
Esempio n. 13
0
int test_function_arity(void)
{
    int arity;

    setup_function_set();
    arity = function_arity(0, fs);
    mu_check(arity == 2);
    teardown_function_set();

    return 0;
}
Esempio n. 14
0
void 
mu_test_options () 
{
  struct balloon_options opts;
  opts.m_cost = 0;
  opts.t_cost = 10000llu;
  opts.n_neighbors = 1;
  opts.comp_opts.comp = 0;
  opts.comp_opts.comb = 0;
  opts.mix = 0; 
  opts.n_threads = 1;

  opts.m_cost = 1024;
  mu_check ( !options_validate (&opts) );

  opts.t_cost = 0;
  mu_check ( !options_validate (&opts) );

  opts.t_cost = 3;
  opts.n_neighbors = 0;
  mu_check ( options_validate (&opts) );
}
Esempio n. 15
0
int test_function_set_new_and_destroy(void)
{
    int i;

    setup_function_set();
    mu_check(fs != NULL);

    for (i = 0; i < 9; i++) {
        mu_print("function number: %d\t", fs->functions[i]->function);
        mu_print("arity: %d\n", fs->functions[i]->arity);
    }

    teardown_function_set();
    return 0;
}
Esempio n. 16
0
void 
mu_test_validate_parameters__saltlen () 
{
  size_t outlen;
  size_t inlen;
  size_t saltlen;

  outlen = 32;
  inlen = 1024;
  saltlen = 32;
  mu_check ( validate_parameters (outlen, inlen, saltlen) == 0 );

  saltlen = 0;
  mu_check ( validate_parameters (outlen, inlen, saltlen) == ERROR_SALTLEN_TOO_SMALL );

  saltlen = SALTLEN_MIN - 1;
  mu_check ( validate_parameters (outlen, inlen, saltlen) == ERROR_SALTLEN_TOO_SMALL );

  saltlen = 1 << 24;
  mu_check ( validate_parameters (outlen, inlen, saltlen) == ERROR_SALTLEN_TOO_BIG);

  saltlen = SALTLEN_MAX;
  mu_check ( validate_parameters (outlen, inlen, saltlen) == ERROR_SALTLEN_TOO_BIG);
}
Esempio n. 17
0
int test_evolve_new_and_destroy(void)
{
    struct config *c = config_new();
    float solution = -1.0f;

    mu_check(c->max_generations == -1);
    mu_check(c->population_size == -1);
    mu_check(c->population_generator == NULL);

    mu_check(c->stale_limit == -1);
    mu_check(fltcmp(&c->target_score, &solution) == 0);

    mu_check(c->data_struct == NULL);

    mu_check(c->selection == NULL);
    mu_check(c->crossover == NULL);
    mu_check(c->mutation == NULL);

    config_destroy(c);
    return 0;
}
Esempio n. 18
0
int test_function_new_and_destroy(void)
{
    f = function_new(DEFAULT, 0, 2);
    mu_check(f->type == DEFAULT);
    mu_check(f->function == 0);
    mu_check(f->arity == 2);
    function_destroy(f);

    /* default function */
    f = function_new_func(0, 2);
    mu_check(f->type == DEFAULT);
    mu_check(f->function == 0);
    mu_check(f->arity == 2);
    function_destroy(f);

    /* classification function */
    f = function_new_cfunc(0, 2);
    mu_check(f->type == CLASSIFICATION);
    mu_check(f->function == 0);
    mu_check(f->arity == 2);
    function_destroy(f);

    return 0;
}
void mu_test_bitbuffer_writeblock() {
    bitbuffer b;

#define WRITEBLOCK_BUFLEN_BYTES 21
    char buff[WRITEBLOCK_BUFLEN_BYTES] = "this is a test array";

    for (size_t i = 1; i <= WRITEBLOCK_BUFLEN_BYTES * 8; i++) {
        bitbuffer_init(&b, WRITEBLOCK_BUFLEN_BYTES);

        memset(b.buffer_origin, 1, WRITEBIT_BUFLEN_BYTES);
        bitbuffer_writeblock(&b, buff, i);

        mu_check(0 == memcmp_bits(buff, b.buffer_origin, i));
        bitbuffer_free(&b);

        check_bitbuffer_location(b, i);
        check_bitbuffer_invariants(b);
    }
}
void mu_test_bitbuffer_pop() {
    bitbuffer b;

#define POP_BUFLEN_BYTES 21
    // initialize the destination buffers to prevent valgrind
    // from complaining becase it doesn't understand bitshifts
    char buff[POP_BUFLEN_BYTES] = "this is a test array";
    char dest[POP_BUFLEN_BYTES] = "                    ";

    for (size_t c = 0; c < POP_BUFLEN_BYTES * 8; c++) {
        bitbuffer_init_from_buffer(&b, (char *)&buff, POP_BUFLEN_BYTES);
        bitbuffer_pop(&dest, &b, c);

        mu_check(0 == memcmp_bits(buff, dest, c + 1));
        check_bitbuffer_invariants(b);
        check_bitbuffer_location(b, c);
        bitbuffer_free(&b);
    };
}
void mu_test_bitbuffer_writebit() {
    bitbuffer b;

#define WRITEBIT_BUFLEN_BYTES 21
    // initialize the destination buffers to prevent valgrind
    // from complaining becase it doesn't understand bitshifts
    char buff[WRITEBIT_BUFLEN_BYTES] = "this is a test array";
    char dest[WRITEBIT_BUFLEN_BYTES] = "                    ";

    bitbuffer_init_from_buffer(&b, dest, WRITEBIT_BUFLEN_BYTES);

    for (size_t i = 0; i < WRITEBIT_BUFLEN_BYTES * 8; i++) {
        bitbuffer_writebit(&b, (buff[i / 8] >> (7 - i % 8)) & 1);
        mu_check(0 == memcmp_bits(buff, dest, i + 1));
        check_bitbuffer_invariants(b);
        check_bitbuffer_location(b, i + 1);
    }

    bitbuffer_free(&b);
}
void mu_test_bitbuffer_next() {
    bitbuffer b;
    char buff[] = "this is a test array";
    bitbuffer_init_from_buffer(&b, (char *)&buff, strlen(buff));

    for (int c = 0; c < (int)strlen(buff); c++) {
        for (int i = 7; i >= 0; i--) {
            bool next = bitbuffer_next(&b);
            bool expected_next = ((buff[c] >> i) & 1);
            // mu_print(MU_SUITE, "%d %d : %d == %d\n",
            //    c, i, next, expected_next);

            mu_check(next == expected_next);
            // one greater than current because we already advanced
            // past current
            check_bitbuffer_location(b, c * 8 + (8 - i));
            check_bitbuffer_invariants(b);
        }
    }

    bitbuffer_free(&b);
}
Esempio n. 23
0
int test_regression_func_input(void)
{
    int i;
    int res;
    float f = 100.0;
    float *f_arr;
    float **func_input;
    struct data *d = csv_load_data(TEST_DATA, 1, ",");
    struct node **stack = malloc(sizeof(struct node *) * 4);

    /* malloc func_input */
    func_input = malloc(sizeof(float *) * 2);
    for (i = 0; i < 2; i++) {
        func_input[i] = malloc(sizeof(float) * (unsigned long) d->rows);
    }

    /* initialize float array */
    f_arr = malloc(sizeof(float) * (unsigned long) d->rows);
    for (i = 0; i < d->rows; i++) {
        f_arr[i] = (float) i;
    }

    /* create stack */
    stack[0] = node_new_input((char *) "x");
    stack[1] = node_new_input((char *) "y");
    stack[2] = node_new_constant(FLOAT, &f);
    stack[3] = node_new_eval(FLOAT, (void *) f_arr, d->rows);

    /* input node - x */
    regression_func_input(stack[0], d, func_input, 0);
    for (i = 0; i < d->rows; i++) {
        res = fltcmp(&func_input[0][i], d->data[data_field_index(d, "x")][i]);
        mu_check(res == 0);
    }

    /* input node - y */
    regression_func_input(stack[1], d, func_input, 1);
    for (i = 0; i < d->rows; i++) {
        res = fltcmp(&func_input[1][i], d->data[data_field_index(d, "y")][i]);
        mu_check(res == 0);
    }

    /* constant node */
    regression_func_input(stack[2], d, func_input, 0);
    for (i = 0; i < d->rows; i++) {
        res = fltcmp(&func_input[0][i], &f);
        mu_check(res == 0);
    }

    /* eval node */
    regression_func_input(stack[3], d, func_input, 0);
    for (i = 0; i < d->rows; i++) {
        f = (float) i;
        res = fltcmp(&func_input[0][i], &f);
        mu_check(res == 0);
    }

    /* clean up */
    node_destroy(stack[0]);
    node_destroy(stack[1]);
    node_destroy(stack[2]);
    node_destroy(stack[3]);
    data_destroy(d);
    free_mem_arr(func_input, 2, free);
    free(stack);

    return 0;
}
Esempio n. 24
0
int test_stack_pop(void)
{
    struct stack *s = stack_new();
    float *f1 = malloc_float(2.0);
    float *f2 = malloc_float(4.0);
    float *f3 = malloc_float(8.0);
    float *flt_ptr;

    /* push float 1 */
    stack_push(s, f1);
    mu_check(fltcmp(s->end->value, f1) == 0);
    mu_check(s->size == 1);
    mu_check(s->root->value == f1);
    mu_check(s->end->prev == NULL);

    /* push float 2 */
    stack_push(s, f2);
    mu_check(fltcmp(s->end->value, f2) == 0);
    mu_check(s->size == 2);
    mu_check(s->root->value == f1);
    mu_check(s->end->prev->value == f1);
    mu_check(fltcmp(s->end->prev->value, f1) == 0);

    /* push float 3 */
    stack_push(s, f3);
    mu_check(fltcmp(s->end->value, f3) == 0);
    mu_check(s->size == 3);
    mu_check(s->root->value == f1);
    mu_check(s->end->prev->value == f2);
    mu_check(fltcmp(s->end->prev->value, f2) == 0);

    /* pop float 3 */
    flt_ptr = stack_pop(s);
    mu_check(fltcmp(flt_ptr, f3) == 0);
    mu_check(s->size == 2);
    mu_check(s->root->value == f1);
    mu_check(fltcmp(s->root->value, f1) == 0);
    free(flt_ptr);

    /* pop float 2 */
    flt_ptr = stack_pop(s);
    mu_check(fltcmp(flt_ptr, f2) == 0);
    mu_check(s->size == 1);
    mu_check(s->root->value == f1);
    mu_check(fltcmp(s->root->value, f1) == 0);
    free(flt_ptr);

    /* pop float 1 */
    flt_ptr = stack_pop(s);
    mu_check(fltcmp(flt_ptr, f1) == 0);
    mu_check(s->size == 0);
    mu_check(s->root == NULL);
    mu_check(s->end == NULL);
    free(flt_ptr);

    stack_destroy(s, free);
    return 0;
}
inline void check_bitbuffer_location(bitbuffer b, size_t bits) {
    mu_check(bits == (size_t)(b.buffer - b.buffer_origin) * 8 + b.head_offset);
}
Esempio n. 26
0
void mu_test_list()
{
    my_t n1 = {{{0}, {0}}, 1};
    my_t n2 = {{{0}, {0}}, 2};
    my_t n3 = {{{0}, {0}}, 3};
    my_t n4 = {{{0}, {0}}, 4};
    my_t n5 = {{{0}, {0}}, 5};
    my_t n6 = {{{0}, {0}}, 6};

    list_t list;
    list_init(&list);

    // 5 -> 1
    list_push_back(&n5.link, &list);
    list_insert_after(&n5.link, &n1.link, &list);

    mu_check( list_next(&n5.link) == &n1.link);
    mu_check( list_last(&n5.link) == &n1.link);
    mu_check( list_last(&n1.link) == &n1.link);
    mu_check( list_first(&n1.link) == &n5.link);

    // 5 -> 3 -> 1
    list_insert_befor(&n1.link, &n3.link, &list);

    mu_check( list_next(&n5.link) == &n3.link);
    mu_check( list_last(&n5.link) == &n1.link);
    mu_check( list_prev(&n1.link) == &n3.link);
    mu_check( list_first(&n3.link) == &n5.link);

    // 1 -> 3 -> 5
    list_swap(&n5.link, &n1.link, &list);

    mu_check( list_next(&n1.link) == &n3.link);
    mu_check( list_last(&n1.link) == &n5.link);
    mu_check( list_prev(&n5.link) == &n3.link);
    mu_check( list_first(&n3.link) == &n1.link);

    // 5 -> 3 -> 1
    list_swap(&n5.link, &n1.link, &list);

    mu_check( list_next(&n5.link) == &n3.link);
    mu_check( list_last(&n5.link) == &n1.link);
    mu_check( list_prev(&n1.link) == &n3.link);
    mu_check( list_first(&n3.link) == &n5.link);

    // 2 -> 5 -> 3 -> 1
    list_push_front(&n2.link, &list);

    mu_check( !list_prev(&n2.link));
    mu_check( list_last(&n2.link) == &n1.link);
    mu_check( list_prev(&n5.link) == &n2.link);
    mu_check( list_first(&n3.link) == &n2.link);

    // 2 -> 5 -> 3 -> 1 -> 4
    list_push_back(&n4.link, &list);
    print(list_first(&n2.link));


    mu_check( !list_next(&n4.link));
    mu_check( list_last(&n2.link) == &n4.link);
    mu_check( list_prev(&n4.link) == &n1.link);
    mu_check( list_next(&n1.link) == &n4.link);
    mu_check( list_first(&n4.link) == &n2.link);

    // 2 -> 5 -> 1 -> 4
    list_remove(&n3.link, &list);

    mu_check( list_next(&n5.link) == &n1.link);
    mu_check( list_prev(&n1.link) == &n5.link);

    // 2 -> 6 -> 1 -> 4
    list_replace(&n5.link, &n6.link, &list);

    mu_check( list_next(&n6.link) == &n1.link);
    mu_check( list_prev(&n1.link) == &n6.link);
    mu_check( list_prev(&n6.link) == &n2.link);

    // 2 -> 1 -> 6 -> 4
    list_swap(&n6.link, &n1.link, &list);

    mu_check( list_next(&n1.link) == &n6.link);
    mu_check( list_prev(&n6.link) == &n1.link);
    mu_check( list_next(&n6.link) == &n4.link);

    // 2 -> 6 -> 1 -> 4
    list_swap(&n6.link, &n1.link, &list);

    mu_check( list_next(&n6.link) == &n1.link);
    mu_check( list_prev(&n1.link) == &n6.link);
    mu_check( list_next(&n1.link) == &n4.link);
    mu_check( list_prev(&n6.link) == &n2.link);

    mu_check( list_front(&list) == &n2.link);
    mu_check( list_back(&list) == &n4.link);

    puts("pre sort:");
    print(list_first(&n1.link));    

    list_sort(&list, my_cmp);
    puts("post sort:");
    print(list_first(&n1.link));
}
Esempio n. 27
0
int test_regression_traverse(void)
{
    int i;
    int res;
    float f1 = 1.0;
    float f2 = 2.0;
    float f3;
    float *flt_ptr;
    float zero = 0.0;
    float **func_input;
    struct node *result_node;
    struct node **chromosome = malloc(sizeof(struct node *) * 3);
    struct stack *stack = stack_new();
    struct data *d = csv_load_data(TEST_DATA, 1, ",");

    /* initialize func_input */
    func_input = malloc(sizeof(float *) * 2);
    for (i = 0; i < 2; i++) {
        func_input[i] = malloc(sizeof(float) * (unsigned long) d->rows);
    }

    /* ADD */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &f2);
    chromosome[2] = node_new_func(ADD, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = f1 + f2;
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 3);


    /* SUB */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &f2);
    chromosome[2] = node_new_func(SUB, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = f1 - f2;
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 3);


    /* MUL */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &f2);
    chromosome[2] = node_new_func(MUL, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = f1 * f2;
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 3);


    /* DIV */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &f2);
    chromosome[2] = node_new_func(DIV, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = f1 / f2;
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 3);


    /* DIV - FAIL TEST - DIVIDE BY ZERO */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &zero);
    chromosome[2] = node_new_func(DIV, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);
    mu_check(res == -1);
    free_chromosome(chromosome, 3);


    /* POW */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_constant(FLOAT, &f2);
    chromosome[2] = node_new_func(POW, 2);
    res = regression_traverse(0, 2, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) pow(f1, f2);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 3);


    /* LOG */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(LOG, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) log(f1);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 2);


    /* EXP */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(EXP, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) exp(f1);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 2);

    /* RAD */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(RAD, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) f1 * (float) (PI / 180.0);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 2);


    /* SIN */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(SIN, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) sin(f1);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 2);


    /* COS */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(COS, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);

    result_node = stack_pop(stack);
    for (i = 0; i < d->rows; i++) {
        f3 = (float) cos(f1);
        flt_ptr = &((float *) result_node->values)[i];
        mu_check(fltcmp(flt_ptr, &f3) == 0);
    }
    node_destroy(result_node);
    free_chromosome(chromosome, 2);


    /* FAIL TEST - UNKNOWN FUNCTION */
    chromosome[0] = node_new_constant(FLOAT, &f1);
    chromosome[1] = node_new_func(99, 1);
    res = regression_traverse(0, 1, chromosome, stack, func_input, d);
    mu_check(res == -2);
    free_chromosome(chromosome, 2);


    /* clean up */
    stack_destroy(stack, free);
    free(chromosome);
    data_destroy(d);
    free_mem_arr(func_input, 2, free);
    return 0;
}