diff options
author | Amr Hesham <amr96@programmer.net> | 2025-02-06 13:11:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-06 13:11:11 +0100 |
commit | 2464f4ba6e0e50bb30c31b6526fa0bdd5a531217 (patch) | |
tree | 1cc7e77a0154b4dd0feb63bae70159180eb3fa8f /llvm/unittests/Support/ErrorTest.cpp | |
parent | d0f472c246911e35656bf24fd282f80d7482211a (diff) | |
download | llvm-2464f4ba6e0e50bb30c31b6526fa0bdd5a531217.zip llvm-2464f4ba6e0e50bb30c31b6526fa0bdd5a531217.tar.gz llvm-2464f4ba6e0e50bb30c31b6526fa0bdd5a531217.tar.bz2 |
[LLVM][Support] Add new CreateFileError functions (#125906)
Add new CreateFileError functions to create a StringError with the
specified error code and prepend the file path to it
Needed for: #125345
Diffstat (limited to 'llvm/unittests/Support/ErrorTest.cpp')
-rw-r--r-- | llvm/unittests/Support/ErrorTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index 98d19e8..00c562e 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -976,6 +976,17 @@ TEST(Error, FileErrorTest) { handleAllErrors(std::move(FE6), [](std::unique_ptr<FileError> F) { EXPECT_EQ(F->messageWithoutFileInfo(), "CustomError {6}"); }); + + Error FE7 = + createFileError("file.bin", make_error_code(std::errc::invalid_argument), + "invalid argument"); + EXPECT_EQ(toString(std::move(FE7)), "'file.bin': invalid argument"); + + StringRef Argument = "arg"; + Error FE8 = + createFileError("file.bin", make_error_code(std::errc::invalid_argument), + "invalid argument '%s'", Argument.str().c_str()); + EXPECT_EQ(toString(std::move(FE8)), "'file.bin': invalid argument 'arg'"); } TEST(Error, FileErrorErrorCode) { |