Skip to content

Commit

Permalink
Merge pull request #66 from SeanMcG/unittest-dirpaths
Browse files Browse the repository at this point in the history
add unit tests for DirPaths
  • Loading branch information
Galladite27 authored Sep 9, 2024
2 parents 9c92965 + d4d7e15 commit a416b3d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ test_BaseReader$(EXESUFFIX): test_BaseReader.cpp $(TOPSRC)/BaseReader.h libgtest
$(Q)$(CXX) $(CXXSTD) -isystem $(GTEST_INCDIR) -I$(TOPSRC) $(CXXFLAGS) $^ -o $@
./$@

TESTEXE := test_Encoding$(EXESUFFIX) test_BaseReader$(EXESUFFIX)
test_DirPaths$(EXESUFFIX): test_DirPaths.cpp $(TOPSRC)/DirPaths.cpp libgtest$(LIBSUFFIX)
$(Q)$(CXX) $(CXXSTD) -isystem $(GTEST_INCDIR) -I$(TOPSRC) $(CXXFLAGS) $^ -o $@
./$@

TESTEXE := test_Encoding$(EXESUFFIX) test_BaseReader$(EXESUFFIX) test_DirPaths$(EXESUFFIX)

test: $(TESTEXE)

Expand Down
55 changes: 55 additions & 0 deletions test/test_DirPaths.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "DirPaths.h"

#include "gtest/gtest.h"

namespace {

TEST (DirPathsTest, ConstructorWithPath) {
std::string path = ".";
const DirPaths dp(path.c_str());
EXPECT_EQ(1, dp.get_num_paths());
}

TEST (DirPathsTest, CopyConstructor) {
std::string path = ".";
const DirPaths dp(path.c_str());
const DirPaths d2 = dp;
EXPECT_EQ(1, dp.get_num_paths());
EXPECT_EQ(1, d2.get_num_paths());
}

TEST (DirPathsTest, OperatorEquals) {
DirPaths dp;
DirPaths const d2;
dp = d2;
EXPECT_EQ(0, dp.get_num_paths());
EXPECT_EQ(0, d2.get_num_paths());
}

TEST (DirPathsTest, addWithDirPaths) {
std::string path = ".";
DirPaths dp(path.c_str());
DirPaths d2(path.c_str());
dp.add(d2);
EXPECT_EQ(2, dp.get_num_paths());
}

TEST (DirPathsTest, get_path) {
std::string path = ".";
DirPaths dp(path.c_str());
EXPECT_TRUE(dp.get_path(0));
}

TEST (DirPathsTest, get_all_paths) {
std::string path = ".";
DirPaths dp(path.c_str());
EXPECT_TRUE(dp.get_all_paths());
}

TEST (DirPathsTest, max_path_len) {
std::string path = ".";
DirPaths dp(path.c_str());
EXPECT_EQ(2, dp.max_path_len());
}

} // namespace

0 comments on commit a416b3d

Please sign in to comment.