| 284 | |
| 285 | template <typename T1, typename T2> |
| 286 | ::testing::AssertionResult |
| 287 | VectorRMSPredFormat(const char * expr1, |
| 288 | const char * expr2, |
| 289 | const char * rms_error_expr, |
| 290 | const std::vector<T1> & val1, |
| 291 | const std::vector<T2> & val2, |
| 292 | double rms_error) |
| 293 | { |
| 294 | if (val1.size() != val2.size()) |
| 295 | { |
| 296 | return testing::AssertionFailure() << "The size of " << expr1 << " and " << expr2 << " different, where\n" |
| 297 | << expr1 << " evaluates to " << val1 << ",\n" |
| 298 | << expr2 << " evaluates to " << val2 << "."; |
| 299 | } |
| 300 | double total = 0.0; |
| 301 | for (unsigned int i = 0; i < val1.size(); ++i) |
| 302 | { |
| 303 | const double temp = static_cast<double>(val1[i] - val2[i]); |
| 304 | total += temp * temp; |
| 305 | } |
| 306 | const double rms = sqrt(total); |
| 307 | if (rms <= rms_error) |
| 308 | return ::testing::AssertionSuccess(); |
| 309 | |
| 310 | return ::testing::AssertionFailure() << "The RMS difference between " << expr1 << " and " << expr2 << " is " << rms |
| 311 | << ",\n which exceeds " << rms_error_expr << ", where\n" |
| 312 | << expr1 << " evaluates to " << val1 << ",\n" |
| 313 | << expr2 << " evaluates to " << val2 << ", and\n" |
| 314 | << rms_error_expr << " evaluates to " << rms_error << "."; |
| 315 | } |
| 316 | |
| 317 | |
| 318 | #define EXPECT_VECTOR_DOUBLE_NEAR(val1, val2, rms_error) \ |
nothing calls this directly
no outgoing calls
no test coverage detected