Hi everyone,
I couldn't find a way to check if two floating-point arrays matches (they don't need to be exactly equal, just nearly equal each other). For integer arrays and other sorts of arrays that can use operator ==, I was successfull using ElementsAreArray() like this:
const int expected_array[kArraySize] = { ... };
int actual_array[kArraySize];
// call method that fills actual_array
EXPECT_THAT(expected_array, ::testing::ElementsAreArray(actual_array, array_size));
But if the arrays are floating-point (float or double), ElementsAreArray also uses matcher Eq(), so my test fails. How can I check if two FP arrays are nearly equal? Is there any built-in way to apply matcher FloatEq() to all elements of an array?
Thanks,
Daniel P. Volpato