summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index f7e3b398c87..c2a1673f42d 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -544,4 +544,23 @@ TEST(Error, ErrorCodeConversions) {
}
}
+// Test that error messages work.
+TEST(Error, ErrorMessage) {
+ EXPECT_EQ(toString(Error::success()).compare(""), 0);
+
+ Error E1 = make_error<CustomError>(0);
+ EXPECT_EQ(toString(std::move(E1)).compare("CustomError { 0}"), 0);
+
+ Error E2 = make_error<CustomError>(0);
+ handleAllErrors(std::move(E2), [](const CustomError &CE) {
+ EXPECT_EQ(CE.message().compare("CustomError { 0}"), 0);
+ });
+
+ Error E3 = joinErrors(make_error<CustomError>(0), make_error<CustomError>(1));
+ EXPECT_EQ(toString(std::move(E3))
+ .compare("CustomError { 0}\n"
+ "CustomError { 1}"),
+ 0);
+}
+
} // end anon namespace
OpenPOWER on IntegriCloud