Skip to content

Commit 2632ece

Browse files
committed
Moved tests to unit-tests
1 parent a4fbcf9 commit 2632ece

File tree

13 files changed

+120
-688
lines changed

13 files changed

+120
-688
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
wsjcpp-yaml
22
tmp/*
33
.wsjcpp-yaml-logs/*
4+
.vscode
45

56
# Prerequisites
67
*.d

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project(wsjcpp-yaml)
55
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
66

77
set(CMAKE_CXX_STANDARD 11)
8-
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp_SOURCE_DIR})
8+
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp-yaml_SOURCE_DIR})
99

1010
# Sources
1111

src/main.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,6 @@ void check(std::string sTestName, bool bGotValue, bool bExpectedValue) {
5050
Log::ok(sTestName, "fine");
5151
};
5252

53-
void testLine(
54-
int nNumberOfTest,
55-
std::string sLine,
56-
std::string sPrefix,
57-
bool isArrayItem,
58-
std::string sName,
59-
std::string sValue,
60-
std::string sComment
61-
) {
62-
std::string TAG = "LINE" + std::to_string(nNumberOfTest);
63-
WSJCppYAMLParsebleLine line(nNumberOfTest);
64-
Log::info(TAG, "Test line" + std::to_string(nNumberOfTest) + ": '" + sLine + "'");
65-
line.parseLine(sLine);
66-
check(TAG + "-prefix", line.getPrefix(), sPrefix);
67-
check(TAG + "-arrayitem", line.isArrayItem(), isArrayItem);
68-
check(TAG + "-name", line.getName(), sName);
69-
check(TAG + "-value", line.getValue(), sValue);
70-
check(TAG + "-comment", line.getComment(), sComment);
71-
};
7253

7354
int main(int argc, char* argv[]) {
7455
std::string TAG = "MAIN";
@@ -80,13 +61,6 @@ int main(int argc, char* argv[]) {
8061
Fallen::makeDir(appLogPath);
8162
}
8263

83-
// tests for line parser
84-
testLine(1, "# Some comment 1 ", "", false, "", "", " Some comment 1 ");
85-
testLine(2, " test2: \"t\\\"wo\" # some comment 2", " ", false, "test2", "t\"wo", " some comment 2");
86-
testLine(3, " test3:", " ", false, "test3", "", "");
87-
testLine(4, " - test4", " ", true, "", "test4", "");
88-
testLine(5, "", "", false, "", "", "");
89-
9064
// tests
9165

9266

unit-tests/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
tmp/*
1+
tmp/*
2+
logs/*
3+
unit-tests

unit-tests/CMakeLists.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
project(wsjcpp-yaml)
4-
5-
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
3+
project(unit-tests)
64

75
set(CMAKE_CXX_STANDARD 11)
8-
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp_SOURCE_DIR})
6+
set(EXECUTABLE_OUTPUT_PATH ${unit-tests_SOURCE_DIR})
7+
8+
set (WSJCPP_LIBRARIES "")
9+
set (WSJCPP_INCLUDE_DIRS "")
10+
set (WSJCPP_SOURCES "")
911

1012
# Sources
1113

14+
# wsjcpp-logger
15+
list (APPEND WSJCPP_SOURCES "../src.wsjcpp/wsjcpp-logger/fallen.cpp")
16+
list (APPEND WSJCPP_SOURCES "../src.wsjcpp/wsjcpp-logger/fallen.h")
17+
list (APPEND WSJCPP_INCLUDE_DIRS "../src.wsjcpp/wsjcpp-logger/")
18+
19+
# wsjcpp-yaml
20+
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_yaml.h")
21+
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_yaml.cpp")
22+
1223
# include header dirs
1324
list (APPEND WSJCPP_INCLUDE_DIRS "../src")
1425
list (APPEND WSJCPP_INCLUDE_DIRS "src")
1526

16-
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_yaml.h")
17-
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_yaml.cpp")
27+
1828
list (APPEND WSJCPP_SOURCES "./src/unit_tests.h")
1929
list (APPEND WSJCPP_SOURCES "./src/unit_tests.cpp")
30+
list (APPEND WSJCPP_SOURCES "./src/unit_test_line_parser.h")
31+
list (APPEND WSJCPP_SOURCES "./src/unit_test_line_parser.cpp")
2032
list (APPEND WSJCPP_SOURCES "./src/main.cpp")
2133

2234
include_directories(${WSJCPP_INCLUDE_DIRS})
2335

24-
add_executable ("wsjcpp-yaml-tests" ${WSJCPP_SOURCES})
36+
add_executable ("unit-tests" ${WSJCPP_SOURCES})
2537

26-
target_link_libraries("wsjcpp-yaml-tests" -lpthread ${WSJCPP_LIBRARIES} )
38+
target_link_libraries("unit-tests" -lpthread ${WSJCPP_LIBRARIES} )
2739

2840
install(
2941
TARGETS
30-
"wsjcpp-yaml-tests"
42+
"unit-tests"
3143
RUNTIME DESTINATION
3244
/usr/bin
33-
)
45+
)

unit-tests/src.wsjcpp/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

unit-tests/src.wsjcpp/CMakeLists.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)