Convenient method in GoogleTest for a double comparison of not equal?

后端 未结 3 1359
挽巷
挽巷 2021-01-18 01:00

I\'m looking for something similar to the ASSERT_EQ / ASSERT_NE for ASSERT_DOUBLE_EQ.

Maybe I\'m missing an easy way of doing this without having a ASSERT_DOUBLE_NE?

3条回答
  •  隐瞒了意图╮
    2021-01-18 01:36

    You can use the companion mocking framework Google Mock. It has a powerful library of matchers (a la Hamcrest), which you can use with the EXPECT_THAT/ASSERT_THAT macros:

    EXPECT_THAT(value, FloatEq(1));
    EXPECT_THAT(another_value, Not(DoubleEq(3.14)));
    

提交回复
热议问题