summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp9
-rw-r--r--llvm/unittests/Support/FileOutputBufferTest.cpp11
-rw-r--r--llvm/unittests/Support/Host.cpp11
-rw-r--r--llvm/unittests/Support/Path.cpp22
-rw-r--r--llvm/unittests/Support/ProgramTest.cpp12
-rw-r--r--llvm/unittests/Support/ReplaceFileTest.cpp9
-rw-r--r--llvm/unittests/Support/raw_pwrite_stream_test.cpp11
7 files changed, 68 insertions, 17 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index ec5c30b5fba..c4a9f3e5168 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -933,7 +933,7 @@ public:
class TestErrorCategory : public std::error_category {
public:
- const char *name() const noexcept override { return "test_error"; }
+ const char *name() const noexcept override { return "error"; }
std::string message(int Condition) const override {
switch (static_cast<test_error_code>(Condition)) {
case test_error_code::unspecified:
@@ -975,11 +975,4 @@ TEST(Error, SubtypeStringErrorTest) {
0);
}
-TEST(Error, error_codeErrorMessageTest) {
- EXPECT_NONFATAL_FAILURE(
- EXPECT_EQ(make_error_code(test_error_code::unspecified),
- make_error_code(test_error_code::error_2)),
- "Which is: An unknown error has occurred. (test_error:1)");
-}
-
} // namespace
diff --git a/llvm/unittests/Support/FileOutputBufferTest.cpp b/llvm/unittests/Support/FileOutputBufferTest.cpp
index 24b6b0d4b2a..8afc2125ef4 100644
--- a/llvm/unittests/Support/FileOutputBufferTest.cpp
+++ b/llvm/unittests/Support/FileOutputBufferTest.cpp
@@ -18,7 +18,16 @@
using namespace llvm;
using namespace llvm::sys;
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
+#define ASSERT_NO_ERROR(x) \
+ if (std::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 {
TEST(FileOutputBuffer, Test) {
diff --git a/llvm/unittests/Support/Host.cpp b/llvm/unittests/Support/Host.cpp
index 287daba1db6..ec9dd951a9f 100644
--- a/llvm/unittests/Support/Host.cpp
+++ b/llvm/unittests/Support/Host.cpp
@@ -16,7 +16,16 @@
#include "gtest/gtest.h"
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
+#define ASSERT_NO_ERROR(x) \
+ if (std::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 { \
+ }
using namespace llvm;
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 101f7608004..1802b0031ad 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -38,8 +38,24 @@
using namespace llvm;
using namespace llvm::sys;
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
-#define ASSERT_ERROR(x) ASSERT_NE(x, std::error_code())
+#define ASSERT_NO_ERROR(x) \
+ if (std::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 { \
+ }
+
+#define ASSERT_ERROR(x) \
+ if (!x) { \
+ SmallString<128> MessageStorage; \
+ raw_svector_ostream Message(MessageStorage); \
+ Message << #x ": did not return a failure error code.\n"; \
+ GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
+ }
namespace {
@@ -1249,7 +1265,7 @@ TEST_F(FileSystemTest, OpenFileForRead) {
int FileDescriptor2;
SmallString<64> ResultPath;
ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor2,
- fs::OF_None, &ResultPath));
+ fs::OF_None, &ResultPath))
// If we succeeded, check that the paths are the same (modulo case):
if (!ResultPath.empty()) {
diff --git a/llvm/unittests/Support/ProgramTest.cpp b/llvm/unittests/Support/ProgramTest.cpp
index 6a1438bac9f..85a1d532c9a 100644
--- a/llvm/unittests/Support/ProgramTest.cpp
+++ b/llvm/unittests/Support/ProgramTest.cpp
@@ -35,8 +35,16 @@ void sleep_for(unsigned int seconds) {
#error sleep_for is not implemented on your platform.
#endif
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
-
+#define ASSERT_NO_ERROR(x) \
+ if (std::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 { \
+ }
// From TestMain.cpp.
extern const char *TestMainArgv0;
diff --git a/llvm/unittests/Support/ReplaceFileTest.cpp b/llvm/unittests/Support/ReplaceFileTest.cpp
index 9a870a78360..d2273d77f5e 100644
--- a/llvm/unittests/Support/ReplaceFileTest.cpp
+++ b/llvm/unittests/Support/ReplaceFileTest.cpp
@@ -17,7 +17,14 @@
using namespace llvm;
using namespace llvm::sys;
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
+#define ASSERT_NO_ERROR(x) \
+ do { \
+ if (std::error_code ASSERT_NO_ERROR_ec = x) { \
+ errs() << #x ": did not return errc::success.\n" \
+ << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
+ << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
+ } \
+ } while (false)
namespace {
std::error_code CreateFileWithContent(const SmallString<128> &FilePath,
diff --git a/llvm/unittests/Support/raw_pwrite_stream_test.cpp b/llvm/unittests/Support/raw_pwrite_stream_test.cpp
index b2a7434fb53..459eb940a43 100644
--- a/llvm/unittests/Support/raw_pwrite_stream_test.cpp
+++ b/llvm/unittests/Support/raw_pwrite_stream_test.cpp
@@ -15,7 +15,16 @@
using namespace llvm;
-#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
+#define ASSERT_NO_ERROR(x) \
+ if (std::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 {
OpenPOWER on IntegriCloud