From f9fd07864e992e6d934f05d5760e5600c399c6f0 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Thu, 6 Jan 2011 05:57:54 +0000 Subject: [PATCH] UnitTests/Path: More ASSERT_NO_ERROR cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122947 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/Path.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index bc39a223ae3..a84ea732dab 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/PathV2.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -17,12 +18,13 @@ using namespace llvm; using namespace llvm::sys; #define ASSERT_NO_ERROR(x) \ - if (error_code ec = x) { \ - SmallString<128> Message; \ - GTEST_FATAL_FAILURE_((Twine(#x ": did not return errc::success.\n") + \ - "error number: " + Twine(ec.value()) + "\n" + \ - "error message: " + \ - ec.message()).toNullTerminatedStringRef(Message).data()); \ + if (error_code ASSERT_NO_ERROR_ec = x) { \ + SmallString<128> MessageStorage; \ + raw_svector_ostream Message(MessageStorage); \ + Message << #x ": did not return errc::success.\n" \ + << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ + << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ + GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \ } else {} namespace { @@ -206,12 +208,9 @@ TEST_F(FileSystemTest, TempFiles) { TEST_F(FileSystemTest, DirectoryIteration) { error_code ec; - for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) { - if (ec) { - errs() << ec.message() << '\n'; - errs().flush(); - report_fatal_error("Directory iteration failed!"); - } + for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) + ASSERT_NO_ERROR(ec); +} } }