From ff92522b8ce6903e679bb3407eb2dbdcf662440b Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 24 Jan 2022 14:58:48 +0100 Subject: [PATCH] Test: Add stderr stream pointer to the test suite --- test/testdotfile.cpp | 6 ++++-- test/testsuite.cpp | 1 + test/testsuite.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/testdotfile.cpp b/test/testdotfile.cpp index b6663f7..d195075 100644 --- a/test/testdotfile.cpp +++ b/test/testdotfile.cpp @@ -4,11 +4,10 @@ * SPDX-License-Identifier: MIT */ -#include +#include // stderr #include #include #include // geteuid, setegid, seteuid -#include #include #include "dotfile.h" @@ -111,7 +110,10 @@ TEST_CASE(AddDotfiles) TEST_CASE(AddNonExistentDotfiles) { + stderr = Test::TestSuite::the().outputNull(); Dotfile::the().add({ "/tmp/__non-existent-test-file" }); + stderr = Test::TestSuite::the().outputErr(); + EXPECT(!std::filesystem::exists("__non-existent-test-file")); } diff --git a/test/testsuite.cpp b/test/testsuite.cpp index c3b09bf..97d4c1b 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -11,6 +11,7 @@ namespace Test { TestSuite::TestSuite(s) { m_outputStd = stdout; + m_outputErr = stderr; m_outputNull = fopen("/dev/null", "w"); // Windows: nul } diff --git a/test/testsuite.h b/test/testsuite.h index 9ab8ea0..0a61f3a 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -19,11 +19,13 @@ public: void currentTestCaseFailed() { m_currentTestCasePassed = false; } FILE* outputStd() const { return m_outputStd; } + FILE* outputErr() const { return m_outputErr; } FILE* outputNull() const { return m_outputNull; } private: bool m_currentTestCasePassed { true }; FILE* m_outputStd { nullptr }; + FILE* m_outputErr { nullptr }; FILE* m_outputNull { nullptr }; std::vector m_cases;