Skip to content

Commit

Permalink
Added test struct to create some prerequisites for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bialger committed Jan 18, 2024
1 parent 58eb3d0 commit 74b5c1f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/main_test.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#include <sstream>
#include <filesystem>

#include <gtest/gtest.h> // 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<std::string> SplitString(const std::string& str) {
std::istringstream iss(str);

return {std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>()};
}

TEST_F(TemporaryDirectoryTestSuite, InitTest) {
ASSERT_TRUE(std::filesystem::is_directory(dirname));
}

TEST(MyLibUnitTestSuite, BasicTest1) {
std::ostringstream out;
MyClass printer(out);
Expand Down

0 comments on commit 74b5c1f

Please sign in to comment.