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

resolve #4612 Feature add EXPECT/ASSERT_FLOAT/DOUBLE_NE (not equal) #4670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

daniel10015
Copy link

@daniel10015 daniel10015 commented Nov 26, 2024

A "not equal" feature was added to complement the "equal" feature for float and double. A simple way to negate the *_EQ is to use an internal macro, EXPECT_NONFATAL_FAILURE(stmt, substr):

// A macro for testing Google Test assertions or code that's expected to
// generate Google Test non-fatal failures (e.g. a failure from an EXPECT_EQ,
// but not from an ASSERT_EQ). It asserts that the given statement will cause
// exactly one non-fatal Google Test failure with 'substr' being part of the
// failure message.

This is not meant to be used when using gtest. Instead, what is proposed is a way of testing for inequality that follows equality. Test cases were made that test the semantics of the macro. Test cases were not made where the internal testing is computed, since the underlying code for both are the same, except for minor adjustments that don't modify the underlying flow of the program.

The following macros were created:

EXPECT_FLOAT_NE
EXPECT_DOUBLE_NE
ASSERT_FLOAT_NE
ASSERT_DOUBLE_NE

Two helper functions were created:

::testing::internal::CmpHelperFloatingPointNE<float>
::testing::internal::CmpHelperFloatingPointNE<double>

fixes #4612

@daniel10015 daniel10015 changed the title Feature add EXPECT/ASSERT_FLOAT/DOUBLE_NE (not equal) Address Issue #4612 Feature add EXPECT/ASSERT_FLOAT/DOUBLE_NE (not equal) Nov 26, 2024
@daniel10015 daniel10015 changed the title Address Issue #4612 Feature add EXPECT/ASSERT_FLOAT/DOUBLE_NE (not equal) resolve #4612 Feature add EXPECT/ASSERT_FLOAT/DOUBLE_NE (not equal) Nov 26, 2024
@daniel10015 daniel10015 marked this pull request as ready for review November 26, 2024 19:27
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 this pull request may close these issues.

[FR]: Add EXPECT_DOUBLE_NE and ASSERT_DOUBLE_NE
1 participant