Skip to content

[FR]: Add EXPECT_DOUBLE_NE and ASSERT_DOUBLE_NE #4612

Open
@Ryanf55

Description

@Ryanf55

Does the feature exist in the most recent commit?

NOPE

Why do we need this feature?

Checking that two doubles are NOT equal is more difficult than it is to check they are equal per S.O.

One approach is to bring in gmock and link to it if you want to check a double value is not equal:

#include <gmock/gmock.h>
#include <gtest/gtest.h>

EXPECT_DOUBLE_EQ(another_value, 3.14);
EXPECT_THAT(another_value, testing::Not(testing::DoubleEq(3.14)));

Describe the proposal.

Here is what I would prefer for the API, which use "NE" like EXPECT_NE

EXPECT_DOUBLE_EQ(another_value, 3.14);
EXPECT_DOUBLE_NE(another_value, 3.14);

Same with

  • EXPECT_FLOAT_NE
  • ASSERT_DOUBLE_NE
  • ASSERT_FLOAT_NE

Is the feature specific to an operating system, compiler, or build system version?

It could be implemented on any OS.

Activity

jordans6

jordans6 commented on Sep 24, 2024

@jordans6

Hi! If this feature hasn't been taken by anyone yet I'd like to work on it!

daniel10015

daniel10015 commented on Nov 24, 2024

@daniel10015

Hi! Looks like a PR hasn't been created yet. @jordans6 are you still working on this? If not, I would like to work on this feature.

oToToT

oToToT commented on Mar 17, 2025

@oToToT
Contributor

Any updates on this?

daniel10015

daniel10015 commented on Mar 17, 2025

@daniel10015

@oToToT I made the changes to my fork and created a PR back in November 2024, however no one has looked at it. For convenience, here is the fork https://github.com/daniel10015/googletest/tree/main and the PR #4670

oToToT

oToToT commented on Mar 17, 2025

@oToToT
Contributor

Hi @derekmauro

Sorry for directly pinging you here. I'm not the issue owner nor the PR submitter. Further, I'm not sure if you're the right person to ask.

Nonetheless, I think having a counterpart to {EXPECT, ASSERT}_{FLOAT, DOUBLE}_EQ, i.e., {EXPECT, ASSERT}_{FLOAT, DOUBLE}_NE, can be helpful and convenient for people using this library. I also find the need for them in my project, so I want to know if there is any more progress that can be done here.

I would like to know if it is possible for you to help review this PR or find the right person to help with this. Please let me (us) know if there is anything wrong about this contribution or the way it was contributed.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @oToToT@Ryanf55@jordans6@daniel10015

      Issue actions

        [FR]: Add EXPECT_DOUBLE_NE and ASSERT_DOUBLE_NE · Issue #4612 · google/googletest