[llvm] 9746b3a - ErrorTest: Break up "ErrorMatchers" test
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 05:20:10 PST 2020
Author: Pavel Labath
Date: 2020-02-19T14:19:48+01:00
New Revision: 9746b3ae07d7320d0cbea83bb9aa2fd73c542c25
URL: https://github.com/llvm/llvm-project/commit/9746b3ae07d7320d0cbea83bb9aa2fd73c542c25
DIFF: https://github.com/llvm/llvm-project/commit/9746b3ae07d7320d0cbea83bb9aa2fd73c542c25.diff
LOG: ErrorTest: Break up "ErrorMatchers" test
This test was getting a bit long. Before adding more checks, group the
existing checks according to the matcher used, and break it up into
smaller tests.
Added:
Modified:
llvm/unittests/Support/ErrorTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index 2cac94d645b7..8b8a621ab50d 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -761,12 +761,22 @@ TEST(Error, Stream) {
}
}
-TEST(Error, ErrorMatchers) {
+TEST(Error, SucceededMatcher) {
EXPECT_THAT_ERROR(Error::success(), Succeeded());
EXPECT_NONFATAL_FAILURE(
EXPECT_THAT_ERROR(make_error<CustomError>(0), Succeeded()),
"Expected: succeeded\n Actual: failed (CustomError {0})");
+ EXPECT_THAT_EXPECTED(Expected<int>(0), Succeeded());
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THAT_EXPECTED(Expected<int>(make_error<CustomError>(0)),
+ Succeeded()),
+ "Expected: succeeded\n Actual: failed (CustomError {0})");
+ int a = 1;
+ EXPECT_THAT_EXPECTED(Expected<int &>(a), Succeeded());
+}
+
+TEST(Error, FailedMatcher) {
EXPECT_THAT_ERROR(make_error<CustomError>(0), Failed());
EXPECT_NONFATAL_FAILURE(EXPECT_THAT_ERROR(Error::success(), Failed()),
"Expected: failed\n Actual: succeeded");
@@ -796,17 +806,14 @@ TEST(Error, ErrorMatchers) {
" Actual: failed (CustomError {0})");
EXPECT_THAT_ERROR(make_error<CustomError>(0), Failed<ErrorInfoBase>());
- EXPECT_THAT_EXPECTED(Expected<int>(0), Succeeded());
- EXPECT_NONFATAL_FAILURE(
- EXPECT_THAT_EXPECTED(Expected<int>(make_error<CustomError>(0)),
- Succeeded()),
- "Expected: succeeded\n Actual: failed (CustomError {0})");
-
EXPECT_THAT_EXPECTED(Expected<int>(make_error<CustomError>(0)), Failed());
EXPECT_NONFATAL_FAILURE(
EXPECT_THAT_EXPECTED(Expected<int>(0), Failed()),
"Expected: failed\n Actual: succeeded with value 0");
+ EXPECT_THAT_EXPECTED(Expected<int &>(make_error<CustomError>(0)), Failed());
+}
+TEST(Error, HasValueMatcher) {
EXPECT_THAT_EXPECTED(Expected<int>(0), HasValue(0));
EXPECT_NONFATAL_FAILURE(
EXPECT_THAT_EXPECTED(Expected<int>(make_error<CustomError>(0)),
@@ -818,9 +825,7 @@ TEST(Error, ErrorMatchers) {
"Expected: succeeded with value (is equal to 0)\n"
" Actual: succeeded with value 1, (isn't equal to 0)");
- EXPECT_THAT_EXPECTED(Expected<int &>(make_error<CustomError>(0)), Failed());
int a = 1;
- EXPECT_THAT_EXPECTED(Expected<int &>(a), Succeeded());
EXPECT_THAT_EXPECTED(Expected<int &>(a), HasValue(testing::Eq(1)));
EXPECT_THAT_EXPECTED(Expected<int>(1), HasValue(testing::Gt(0)));
More information about the llvm-commits
mailing list