UTIL: added test case for the IncludeUtil
parent
65b14dc72a
commit
6e24717e46
|
@ -0,0 +1,2 @@
|
|||
#include "one.h"
|
||||
#include "two.h"
|
|
@ -0,0 +1,2 @@
|
|||
#error "one"
|
||||
#include "two.h"
|
|
@ -0,0 +1 @@
|
|||
#error "two"
|
|
@ -14,12 +14,20 @@ set(TEST_SRCS
|
|||
tests/KeybindingParserTest.cpp
|
||||
tests/KeybindingHandlerTest.cpp
|
||||
tests/EMailValidatorTest.cpp
|
||||
tests/IncludeUtilTest.cpp
|
||||
)
|
||||
set(TEST_FILES
|
||||
testutil/main.h
|
||||
testutil/one.h
|
||||
testutil/two.h
|
||||
)
|
||||
|
||||
gtest_suite_files(tests ${TEST_FILES})
|
||||
gtest_suite_sources(tests ${TEST_SRCS})
|
||||
gtest_suite_deps(tests ${LIB})
|
||||
|
||||
gtest_suite_begin(tests-${LIB} TEMPLATE ${ROOT_DIR}/src/modules/core/tests/main.cpp.in)
|
||||
gtest_suite_files(tests-${LIB} ${TEST_FILES})
|
||||
gtest_suite_sources(tests-${LIB} ${TEST_SRCS} ../core/tests/AbstractTest.cpp)
|
||||
gtest_suite_deps(tests-${LIB} ${LIB})
|
||||
gtest_suite_end(tests-${LIB})
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "core/tests/AbstractTest.h"
|
||||
#include "util/IncludeUtil.h"
|
||||
|
||||
class IncludeUtilTest : public core::AbstractTest {
|
||||
};
|
||||
|
||||
TEST_F(IncludeUtilTest, testInclude) {
|
||||
std::vector<std::string> includedFiles;
|
||||
std::vector<std::string> includeDirs { "." };
|
||||
const std::string src = io::filesystem()->load("main.h");
|
||||
EXPECT_EQ(34u, src.size());
|
||||
std::pair<std::string, bool> retIncludes = util::handleIncludes(src, includeDirs, &includedFiles);
|
||||
EXPECT_TRUE(retIncludes.second);
|
||||
EXPECT_EQ(2u, includedFiles.size());
|
||||
EXPECT_EQ("#error \"one\"\n#include \"two.h\"\n\n#error \"two\"\n\n", retIncludes.first);
|
||||
retIncludes = util::handleIncludes(retIncludes.first, includeDirs, &includedFiles);
|
||||
EXPECT_TRUE(retIncludes.second);
|
||||
EXPECT_EQ(3u, includedFiles.size());
|
||||
EXPECT_EQ("#error \"one\"\n#error \"two\"\n\n\n#error \"two\"\n\n", retIncludes.first);
|
||||
}
|
Loading…
Reference in New Issue