aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/Support/Path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Support/Path.cpp')
-rw-r--r--unittests/Support/Path.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index b79d055..cf2e1ee 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -8,24 +8,30 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Path.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
+#ifdef LLVM_ON_WIN32
+#include <winerror.h>
+#endif
+
using namespace llvm;
using namespace llvm::sys;
-#define ASSERT_NO_ERROR(x) \
- 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 {}
+#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 {
@@ -352,7 +358,7 @@ TEST_F(FileSystemTest, TempFiles) {
ASSERT_EQ(fs::remove(Twine(TempPath2), false),
errc::no_such_file_or_directory);
- error_code EC = fs::status(TempPath2.c_str(), B);
+ std::error_code EC = fs::status(TempPath2.c_str(), B);
EXPECT_EQ(EC, errc::no_such_file_or_directory);
EXPECT_EQ(B.type(), fs::file_type::file_not_found);
@@ -393,7 +399,7 @@ TEST_F(FileSystemTest, TempFiles) {
"abcdefghijklmnopqrstuvwxyz3abcdefghijklmnopqrstuvwxyz2"
"abcdefghijklmnopqrstuvwxyz1abcdefghijklmnopqrstuvwxyz0";
EXPECT_EQ(fs::createUniqueFile(Twine(Path270), FileDescriptor, TempPath),
- windows_error::path_not_found);
+ errc::no_such_file_or_directory);
#endif
}
@@ -406,7 +412,7 @@ TEST_F(FileSystemTest, CreateDir) {
}
TEST_F(FileSystemTest, DirectoryIteration) {
- error_code ec;
+ std::error_code ec;
for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec))
ASSERT_NO_ERROR(ec);
@@ -535,9 +541,6 @@ TEST_F(FileSystemTest, Magic) {
StringRef magic(i->magic_str, i->magic_str_len);
file << magic;
file.close();
- bool res = false;
- ASSERT_NO_ERROR(fs::has_magic(file_pathname.c_str(), magic, res));
- EXPECT_TRUE(res);
EXPECT_EQ(i->magic, fs::identify_magic(magic));
ASSERT_NO_ERROR(fs::remove(Twine(file_pathname)));
}
@@ -555,9 +558,9 @@ TEST_F(FileSystemTest, CarriageReturn) {
File << '\n';
}
{
- std::unique_ptr<MemoryBuffer> Buf;
- MemoryBuffer::getFile(FilePathname.c_str(), Buf);
- EXPECT_EQ(Buf->getBuffer(), "\r\n");
+ auto Buf = MemoryBuffer::getFile(FilePathname.c_str());
+ EXPECT_TRUE((bool)Buf);
+ EXPECT_EQ(Buf.get()->getBuffer(), "\r\n");
}
{
@@ -566,9 +569,9 @@ TEST_F(FileSystemTest, CarriageReturn) {
File << '\n';
}
{
- std::unique_ptr<MemoryBuffer> Buf;
- MemoryBuffer::getFile(FilePathname.c_str(), Buf);
- EXPECT_EQ(Buf->getBuffer(), "\n");
+ auto Buf = MemoryBuffer::getFile(FilePathname.c_str());
+ EXPECT_TRUE((bool)Buf);
+ EXPECT_EQ(Buf.get()->getBuffer(), "\n");
}
ASSERT_NO_ERROR(fs::remove(Twine(FilePathname)));
}
@@ -581,7 +584,7 @@ TEST_F(FileSystemTest, FileMapping) {
ASSERT_NO_ERROR(
fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// Map in temp file and add some content
- error_code EC;
+ std::error_code EC;
StringRef Val("hello there");
{
fs::mapped_file_region mfr(FileDescriptor,