58 ::testing::AssertionResult result = ::testing::AssertionFailure();
59 if (expected.size() != actual.size()) {
60 return result <<
"expected result size=" << expected.size()
61 <<
" differs from actual size=" << actual.size();
63 const unsigned long length = expected.size();
66 const char* separator =
" ";
67 for (
unsigned long index = 0; index < length; index++) {
68 auto expected_real = ::testing::internal::FloatingPoint(expected[index].real());
69 auto expected_imag = ::testing::internal::FloatingPoint(expected[index].imag());
70 auto actual_real = ::testing::internal::FloatingPoint(actual[index].real());
71 auto actual_imag = ::testing::internal::FloatingPoint(actual[index].imag());
72 if (not expected_real.AlmostEquals(actual_real) or
73 not expected_imag.AlmostEquals(actual_imag)) {
74 if (errorsFound == 0) {
75 result <<
"Differences found:";
77 if (errorsFound < 3) {
78 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
85 if (errorsFound > 0) {
86 result << separator << errorsFound <<
" differences in total";
89 return ::testing::AssertionSuccess();
94 const T& expected,
const T& actual,
const float absolute_error = 1.0e-7)
96 ::testing::AssertionResult result = ::testing::AssertionFailure();
97 if (expected.size() != actual.size()) {
98 return result <<
"expected result size=" << expected.size()
99 <<
" differs from actual size=" << actual.size();
101 const unsigned long length = expected.size();
104 const char* separator =
" ";
105 for (
unsigned long index = 0; index < length; index++) {
106 auto expected_real = ::testing::internal::FloatingPoint(expected[index].real());
107 auto expected_imag = ::testing::internal::FloatingPoint(expected[index].imag());
108 auto actual_real = ::testing::internal::FloatingPoint(actual[index].real());
109 auto actual_imag = ::testing::internal::FloatingPoint(actual[index].imag());
110 if (expected_real.is_nan() or actual_real.is_nan() or expected_imag.is_nan() or
111 actual_imag.is_nan() or
112 std::abs(expected[index].real() - actual[index].real()) > absolute_error or
113 std::abs(expected[index].imag() - actual[index].imag()) > absolute_error) {
114 if (errorsFound == 0) {
115 result <<
"Differences found:";
117 if (errorsFound < 3) {
118 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
125 if (errorsFound > 0) {
126 result << separator << errorsFound <<
" differences in total";
129 return ::testing::AssertionSuccess();
134 const T& expected,
const T& actual,
const float absolute_error = 1.0e-7)
136 ::testing::AssertionResult result = ::testing::AssertionFailure();
137 if (expected.size() != actual.size()) {
138 return result <<
"expected result size=" << expected.size()
139 <<
" differs from actual size=" << actual.size();
141 const unsigned long length = expected.size();
144 const char* separator =
" ";
145 for (
unsigned long index = 0; index < length; index++) {
146 auto expected_value = ::testing::internal::FloatingPoint(expected[index]);
147 auto actual_value = ::testing::internal::FloatingPoint(actual[index]);
148 if (expected_value.is_nan() or actual_value.is_nan() or
149 std::abs(expected[index] - actual[index]) > absolute_error) {
150 if (errorsFound == 0) {
151 result <<
"Differences found:";
153 if (errorsFound < 3) {
154 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
161 if (errorsFound > 0) {
162 result << separator << errorsFound <<
" differences in total";
165 return ::testing::AssertionSuccess();