[PATCH] D65643: unittests: Add a (centralized) ability to match std::error_code

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 02:53:03 PDT 2019


labath created this revision.
labath added reviewers: sammccall, ilya-biryukov.
Herald added a project: LLVM.

Currently, matching a std::error_code is done via a long ASSERT_NO_ERROR
macro, which is pasted into every file that needs it. However, nowadays
we have a place to put these kinds of test utilities which are needed in
more that one test file.

This patch reduces code duplication by moving the std::error_code
matching logic into a central place. Instead of just copying the macro,
I also take the opportunity to implementing via the new tools available
from googlemock. I extend the existing Succeeded(), and Failed()
matchers, which already work for Error and Expected<T> types to also
work with std::error_code.

I have reimplemented the existing ASSERT_NO_ERROR macros to reuse the
new functionality, but I did not remove the macros themselves in this
patch to avoid cluttering this review. I am planning to do that in
followup patch(es).


Repository:
  rL LLVM

https://reviews.llvm.org/D65643

Files:
  include/llvm/Testing/Support/Error.h
  unittests/BinaryFormat/TestFileMagic.cpp
  unittests/Support/ErrorTest.cpp
  unittests/Support/FileOutputBufferTest.cpp
  unittests/Support/Host.cpp
  unittests/Support/Path.cpp
  unittests/Support/ProgramTest.cpp
  unittests/Support/ReplaceFileTest.cpp
  unittests/Support/raw_pwrite_stream_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65643.213002.patch
Type: text/x-patch
Size: 15520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190802/912a332f/attachment.bin>


More information about the llvm-commits mailing list