From bdd4e1311830bea92c8b8c09f0644cba15421241 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Wed, 23 Jan 2013 00:18:31 +0000 Subject: [Support][ErrorOr] Add optimized specialization of ErrorOr. ErrorOr represents an operation that returns nothing, but can still fail. It should be used in cases where you need the aditional user data that ErrorOr provides over error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173209 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/ErrorOrTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'unittests/Support') diff --git a/unittests/Support/ErrorOrTest.cpp b/unittests/Support/ErrorOrTest.cpp index b30895c..a860886 100644 --- a/unittests/Support/ErrorOrTest.cpp +++ b/unittests/Support/ErrorOrTest.cpp @@ -45,6 +45,9 @@ TEST(ErrorOr, Types) { *a = 42; EXPECT_EQ(42, x); + EXPECT_FALSE(ErrorOr(make_error_code(errc::broken_pipe))); + EXPECT_TRUE(ErrorOr(make_error_code(errc::success))); + #if LLVM_HAS_CXX11_STDLIB // Move only types. EXPECT_EQ(3, **t3()); @@ -71,10 +74,18 @@ ErrorOr t4() { return InvalidArgError("adena"); } +ErrorOr t5() { + return InvalidArgError("pie"); +} + namespace { TEST(ErrorOr, UserErrorData) { ErrorOr a = t4(); EXPECT_EQ(errc::invalid_argument, a); EXPECT_EQ("adena", t4().getError().ArgName); + + ErrorOr b = t5(); + EXPECT_EQ(errc::invalid_argument, b); + EXPECT_EQ("pie", b.getError().ArgName); } } // end anon namespace -- cgit v1.1