MCPcopy Create free account
hub / github.com/apache/arrow / MatchAndExplain

Method MatchAndExplain

cpp/src/arrow/testing/matchers.h:359–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 };

Callers

nothing calls this directly

Calls 7

UnreachableFunction · 0.85
make_arrayMethod · 0.80
kindMethod · 0.45
ToStringMethod · 0.45
typeMethod · 0.45
schemaMethod · 0.45
DiffMethod · 0.45

Tested by

no test coverage detected