mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 20:18:49 +00:00
Test SystemErrorSink.
This commit is contained in:
parent
78209468a0
commit
6ec1389de2
@ -310,6 +310,23 @@ TEST(UtilTest, SystemError) {
|
|||||||
EXPECT_EQ(42, e.error_code());
|
EXPECT_EQ(42, e.error_code());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: test WinErrorSink, FormatSystemErrorMessage, FormatWinErrorMessage
|
||||||
|
|
||||||
|
TEST(UtilTest, SystemErrorSink) {
|
||||||
|
const int TEST_ERROR = EDOM;
|
||||||
|
fmt::SystemError error("", 0);
|
||||||
|
fmt::SystemErrorSink sink(TEST_ERROR);
|
||||||
|
fmt::Writer w;
|
||||||
|
w << "test";
|
||||||
|
try {
|
||||||
|
sink(w);
|
||||||
|
} catch (const fmt::SystemError &e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
EXPECT_EQ(str(fmt::Format("test: {}") << strerror(TEST_ERROR)), error.what());
|
||||||
|
EXPECT_EQ(TEST_ERROR, error.error_code());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(UtilTest, ThrowSystemError) {
|
TEST(UtilTest, ThrowSystemError) {
|
||||||
const int TEST_ERROR = EDOM;
|
const int TEST_ERROR = EDOM;
|
||||||
fmt::SystemError error("", 0);
|
fmt::SystemError error("", 0);
|
||||||
@ -1695,8 +1712,6 @@ TEST(FormatterTest, FileSinkWriteError) {
|
|||||||
std::fclose(f);
|
std::fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test SystemErrorSink, ThrowSystemError, CErrorSink, ThrowWinError.
|
|
||||||
|
|
||||||
// The test doesn't compile on older compilers which follow C++03 and
|
// The test doesn't compile on older compilers which follow C++03 and
|
||||||
// require an accessible copy constructor when binding a temporary to
|
// require an accessible copy constructor when binding a temporary to
|
||||||
// a const reference.
|
// a const reference.
|
||||||
|
Loading…
Reference in New Issue
Block a user