llvm.org GIT mirror llvm / f9fd078
UnitTests/Path: More ASSERT_NO_ERROR cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122947 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 9 years ago
1 changed file(s) with 11 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
99 #include "llvm/Support/FileSystem.h"
1010 #include "llvm/Support/PathV2.h"
1111 #include "llvm/Support/ErrorHandling.h"
12 #include "llvm/Support/raw_ostream.h"
1213
1314 #include "gtest/gtest.h"
1415
1617 using namespace llvm::sys;
1718
1819 #define ASSERT_NO_ERROR(x) \
19 if (error_code ec = x) { \
20 SmallString<128> Message; \
21 GTEST_FATAL_FAILURE_((Twine(#x ": did not return errc::success.\n") + \
22 "error number: " + Twine(ec.value()) + "\n" + \
23 "error message: " + \
24 ec.message()).toNullTerminatedStringRef(Message).data()); \
20 if (error_code ASSERT_NO_ERROR_ec = x) { \
21 SmallString<128> MessageStorage; \
22 raw_svector_ostream Message(MessageStorage); \
23 Message << #x ": did not return errc::success.\n" \
24 << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
25 << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
26 GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
2527 } else {}
2628
2729 namespace {
205207
206208 TEST_F(FileSystemTest, DirectoryIteration) {
207209 error_code ec;
208 for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) {
209 if (ec) {
210 errs() << ec.message() << '\n';
211 errs().flush();
212 report_fatal_error("Directory iteration failed!");
213 }
210 for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec))
211 ASSERT_NO_ERROR(ec);
212 }
214213 }
215214 }
216215