From 74b5c1f1ca8596db56743d5b6b36317cfa9de764 Mon Sep 17 00:00:00 2001 From: bialger Date: Fri, 19 Jan 2024 00:22:19 +0300 Subject: [PATCH] Added test struct to create some prerequisites for tests --- tests/main_test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/main_test.cpp b/tests/main_test.cpp index 105243a..5fe7fe3 100644 --- a/tests/main_test.cpp +++ b/tests/main_test.cpp @@ -1,14 +1,31 @@ #include +#include #include // include your library here #include "lib/mylib/MyClass.h" +struct TemporaryDirectoryTestSuite : public testing::Test { // special test structure + const std::string dirname = "./gtest_tmp"; + + void SetUp() override { // method that is called at the beginning of every test + std::filesystem::create_directories(dirname); + } + + void TearDown() override { // method that is called at the end of every test + std::filesystem::remove_all(dirname); + } +}; + std::vector SplitString(const std::string& str) { std::istringstream iss(str); return {std::istream_iterator(iss), std::istream_iterator()}; } +TEST_F(TemporaryDirectoryTestSuite, InitTest) { + ASSERT_TRUE(std::filesystem::is_directory(dirname)); +} + TEST(MyLibUnitTestSuite, BasicTest1) { std::ostringstream out; MyClass printer(out);