instead of creating a new CmpHelperFloatingPointNE helper, you can simply define the macro as the inverse of the existing helper:
#include "gtest/gtest.h" #define ASSERT_FLOAT_NE(val1, val2) ASSERT_PRED_FORMAT2( \ !::testing::internal::CmpHelperFloatingPointEQ<float>, val1, val2 \ ) #define ASSERT_DOUBLE_NE(val1, val2) ASSERT_PRED_FORMAT2( \ !::testing::internal::CmpHelperFloatingPointEQ<double>, val1, val2 \ )
This is not as graceful as the deft_code solution, because when the statement fails, there are no specific details such as the "expected value" and "actual value", just the line number and the statement file. However, for my purposes, the line number was enough.
user2337534
source share