summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/ErrorTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/ErrorTest.cpp')
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index 2629e640f79..d03db26df39 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -726,6 +726,30 @@ TEST(Error, ErrorMatchers) {
EXPECT_NONFATAL_FAILURE(EXPECT_THAT_ERROR(Error::success(), Failed()),
"Expected: failed\n Actual: succeeded");
+ EXPECT_THAT_ERROR(make_error<CustomError>(0), Failed<CustomError>());
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THAT_ERROR(Error::success(), Failed<CustomError>()),
+ "Expected: failed with Error of given type\n Actual: succeeded");
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THAT_ERROR(make_error<CustomError>(0), Failed<CustomSubError>()),
+ "Error was not of given type");
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THAT_ERROR(
+ joinErrors(make_error<CustomError>(0), make_error<CustomError>(1)),
+ Failed<CustomError>()),
+ "multiple errors");
+
+ EXPECT_THAT_ERROR(
+ make_error<CustomError>(0),
+ Failed<CustomError>(testing::Property(&CustomError::getInfo, 0)));
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THAT_ERROR(
+ make_error<CustomError>(0),
+ Failed<CustomError>(testing::Property(&CustomError::getInfo, 1))),
+ "Expected: failed with Error of given type and the error is an object "
+ "whose given property is equal to 1\n"
+ " Actual: failed (CustomError { 0})");
+
EXPECT_THAT_EXPECTED(Expected<int>(0), Succeeded());
EXPECT_NONFATAL_FAILURE(
EXPECT_THAT_EXPECTED(Expected<int>(make_error<CustomError>(0)),
OpenPOWER on IntegriCloud