| 357 | } |
| 358 | |
| 359 | bool MatchAndExplain(const Data& data, |
| 360 | testing::MatchResultListener* listener) const override { |
| 361 | Datum boxed(data); |
| 362 | |
| 363 | if (boxed.kind() != expected_.kind()) { |
| 364 | *listener << "whose Datum::kind " << boxed.ToString() << " doesn't match " |
| 365 | << expected_.ToString(); |
| 366 | return false; |
| 367 | } |
| 368 | |
| 369 | if (const auto& boxed_type = boxed.type()) { |
| 370 | if (*boxed_type != *expected_.type()) { |
| 371 | *listener << "whose DataType " << boxed_type->ToString() << " doesn't match " |
| 372 | << expected_.type()->ToString(); |
| 373 | return false; |
| 374 | } |
| 375 | } else if (const auto& boxed_schema = boxed.schema()) { |
| 376 | if (*boxed_schema != *expected_.schema()) { |
| 377 | *listener << "whose Schema " << boxed_schema->ToString() << " doesn't match " |
| 378 | << expected_.schema()->ToString(); |
| 379 | return false; |
| 380 | } |
| 381 | } else { |
| 382 | Unreachable(); |
| 383 | } |
| 384 | |
| 385 | if (boxed == expected_) { |
| 386 | *listener << "whose value matches"; |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | if (listener->IsInterested() && boxed.kind() == Datum::ARRAY) { |
| 391 | *listener << "whose value differs from the expected value by " |
| 392 | << boxed.make_array()->Diff(*expected_.make_array()); |
| 393 | } else { |
| 394 | *listener << "whose value doesn't match"; |
| 395 | } |
| 396 | return false; |
| 397 | } |
| 398 | |
| 399 | Datum expected_; |
| 400 | }; |
nothing calls this directly
no test coverage detected