summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/FormatVariadicTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/FormatVariadicTest.cpp')
-rw-r--r--llvm/unittests/Support/FormatVariadicTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 6d621464c0e..91a44bae3a9 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/FormatAdapters.h"
#include "gtest/gtest.h"
@@ -680,3 +681,11 @@ TEST(FormatVariadicTest, FormatStreamable) {
adl::X X;
EXPECT_EQ("X", formatv("{0}", X).str());
}
+
+TEST(FormatVariadicTest, FormatError) {
+ auto E1 = make_error<StringError>("X", inconvertibleErrorCode());
+ EXPECT_EQ("X", formatv("{0}", E1).str());
+ EXPECT_TRUE(E1.isA<StringError>()); // not consumed
+ EXPECT_EQ("X", formatv("{0}", fmt_consume(std::move(E1))).str());
+ EXPECT_FALSE(E1.isA<StringError>()); // consumed
+}
OpenPOWER on IntegriCloud