google / google/googletest

[FR]: Add EXPECT_DOUBLE_NE and ASSERT_DOUBLE_NE

Open
#4,612 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
39.6k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file or test is named. Start by locating the existing EXPECT_DOUBLE_EQ, EXPECT_FLOAT_EQ, EXPECT_NE, and ASSERT_* assertion entry points in GoogleTest, then compare how these APIs are defined and tested. Done means the four requested floating-point not-equal assertions are available with the proposed names and behave consistently with the existing equality assertions.

Written by the indexing model from the issue text.

Assessment

Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.