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

Extend ZEN_EXPECT with composable EQ, GT, LT, etc. #33

Open
heinsaar opened this issue Mar 13, 2024 · 3 comments
Open

Extend ZEN_EXPECT with composable EQ, GT, LT, etc. #33

heinsaar opened this issue Mar 13, 2024 · 3 comments
Assignees
Labels
tca Must have a test case, can be automated
Milestone

Comments

@heinsaar
Copy link
Owner

heinsaar commented Mar 13, 2024

This will allow expressions like:

ZEN_EXPECT(EQ(x, 4));
ZEN_EXPECT(IS_TRUE(expr));
ZEN_EXPECT(AND(GT(x, 0), LT(x, 10)));

Without sacrificing the simplicity of ZEN_EXPECT(expression) for the most common cases as well as staying backward compatible.

Other benefits of these constructs should be the ability to see the exact value of x at failure; for floating-point comparisons, and other special cases, specialized macros can provide tailored behavior that a universal macro cannot. For example, EXPECT_FLOAT_EQ and EXPECT_DOUBLE_EQ take into account the precision issues inherent in floating-point arithmetic, offering a more appropriate comparison than a straightforward equality check, and maybe more.

Use this advice as a starting point.

@heinsaar heinsaar added easy Good for onboarding, few dependencies tca Must have a test case, can be automated labels Mar 13, 2024
@heinsaar heinsaar added this to the Kaizen 1.0 milestone Mar 13, 2024
@Sudhanva21
Copy link

Can you please assign me this issue, sir? I am interested in solving this
@heinsaar

@heinsaar
Copy link
Owner Author

@Sudhanva21 Sure, assigned. Looking forward to the implementation.

@heinsaar heinsaar removed the easy Good for onboarding, few dependencies label Apr 24, 2024
@Sudhanva21
Copy link

Sudhanva21 commented Apr 25, 2024

Sir, I have added an argument in ZEN_EXPECT to log the value when it fails, as you mentioned in the issue.
So whenever the macro is used it should contain 2 arguments instead of one.

I have made the changes accordingly. Please review it. Committed the changes in same branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tca Must have a test case, can be automated
Projects
None yet
Development

No branches or pull requests

2 participants