google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.78k stars 10.15k forks source link

[FR]: Add EXPECT_DOUBLE_NE and ASSERT_DOUBLE_NE #4612

Open Ryanf55 opened 2 months ago

Ryanf55 commented 2 months ago

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

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

It could be implemented on any OS.

jordans6 commented 1 month ago

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