Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bug that execute an expression in assertion macro twice instead of once #30

Closed
Thecarisma opened this issue Jan 4, 2021 · 2 comments · Fixed by #32
Closed

A bug that execute an expression in assertion macro twice instead of once #30

Thecarisma opened this issue Jan 4, 2021 · 2 comments · Fixed by #32

Comments

@Thecarisma
Copy link
Member

Bug Reproduction

#include <stdio.h>
#include <exotic/cester.h>

CESTER_BODY(
int global_size = 1;
int size() {
    printf("Getting size %d\n", global_size);
    global_size++;
    return global_size;
}
)

CESTER_TEST(test_init_set, _, {
    cester_assert_int_eq(size(), 1);
})

CESTER_OPTIONS(
    CESTER_VERBOSE_LEVEL(2);
)

Notice it prints out "Getting size X" more than once

@Thecarisma
Copy link
Member Author

This appears to occur when cester tries to get the actual expression value for printing it re-evaluates the expression. The solution is to get the evaluation result from the first assertion check

@Thecarisma
Copy link
Member Author

Fixed in the PR #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant