This is an archive of the discontinued LLVM Phabricator instance.

[Support] Add a GTest matcher for Optional<T>
ClosedPublic

Authored by ilya-biryukov on Apr 24 2019, 8:36 AM.

Event Timeline

ilya-biryukov created this revision.Apr 24 2019, 8:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2019, 8:36 AM
sammccall accepted this revision.Apr 24 2019, 10:10 AM
sammccall added inline comments.
llvm/include/llvm/Testing/Support/SupportHelpers.h
110

AFAICS from other helpers, ValueIsMatcher should go in llvm::detail, and ValueIs should go in llvm.

unittest::getInputFileDirectory() reads well, but unittest::ValueIs(...) really doesn't...

130

is this actually necessary? I think it's already going to print the value, which is always "None" - I'm not sure "None, which does not have a value" is clearer.

154

it's a shame the name HasValue is taken, as I think it would much more clearly communicate "has a value *and* the value is...".

This revision is now accepted and ready to land.Apr 24 2019, 10:10 AM
ilya-biryukov marked 6 inline comments as done.
  • Move matcher class to llvm::detail, factory function to llvm
  • Add a simple test
ilya-biryukov added inline comments.Apr 25 2019, 1:57 AM
llvm/include/llvm/Testing/Support/SupportHelpers.h
110

Agreed.

130

Agree, that should be fine

154

Totally agree, couldn't come up with a better name that wasn't taken.

This revision was automatically updated to reflect the committed changes.