Skip to content

Commit 7a60536

Browse files
committed
Merge branch 'testing-integration'
# Conflicts: # src/dbc.hpp
2 parents f746ec6 + 73d18b6 commit 7a60536

File tree

12 files changed

+80
-17664
lines changed

12 files changed

+80
-17664
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Build folders
22
bin/
33
build/
4+
5+
# -- Git -- #
6+
*.bak

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "third_party/Catch2"]
2+
path = third_party/Catch2
3+
url = https://github.com/catchorg/Catch2.git

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(DBC_Tests)
3+
project(DBC)
44

55
# specify the C++ standard
66
set(CMAKE_CXX_STANDARD 11)
@@ -11,8 +11,11 @@ set(GCC_COVERAGE_COMPILE_FLAGS "-g")
1111
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
1212

1313
# add where to find the source files
14+
list(APPEND SOURCE ${PROJECT_SOURCE_DIR}/src/util/utils.cpp)
15+
1416
include_directories(src)
15-
include_directories(test)
17+
include_directories(include)
18+
1619
add_subdirectory(test)
1720
add_subdirectory(doc)
1821

src/dbc.hpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
11

2-
#include <string>
3-
#include <fstream>
4-
#include <iostream>
5-
6-
namespace SafeStr {
7-
8-
/**
9-
* This is a safe non line ending specific getline function. This is to help with files
10-
* carried over from different systems. i.e Unix file comes to Windows with LF endings
11-
* instead of CRLF.
12-
*
13-
* @param stream [description]
14-
* @param line [description]
15-
* @return [description]
16-
*/
17-
std::istream & getline( std::istream & stream, std::string & line ) {
18-
std::string newline;
19-
20-
std::getline( stream, newline );
21-
22-
// Windows CRLF (\r\n)
23-
if ( newline.size() && newline[newline.size()-1] == '\r' ) {
24-
line = newline.substr( 0, newline.size() - 1 );
25-
// MacOS LF (\r)
26-
} else if (newline.size() && newline[newline.size()] == '\r') {
27-
line = newline.replace(newline.size(), 1, "\n");
28-
} else {
29-
line = newline;
30-
}
31-
32-
return stream;
33-
}
34-
35-
}
36-
37-
382
namespace dbc {
393

404
class parser {
415

42-
}
6+
};
437

448
}

src/util/utils.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "util/utils.hpp"
2+
3+
namespace Utils {
4+
5+
std::istream & SafeString::getline( std::istream & stream, std::string & line ) {
6+
std::string newline;
7+
8+
std::getline( stream, newline );
9+
10+
// Windows CRLF (\r\n)
11+
if ( newline.size() && newline[newline.size()-1] == '\r' ) {
12+
line = newline.substr( 0, newline.size() - 1 );
13+
// MacOS LF (\r)
14+
} else if (newline.size() && newline[newline.size()] == '\r') {
15+
line = newline.replace(newline.size(), 1, "\n");
16+
} else {
17+
line = newline;
18+
}
19+
20+
return stream;
21+
}
22+
23+
} // Namespace Utils

src/util/utils.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <string>
2+
#include <fstream>
3+
#include <iostream>
4+
5+
namespace Utils {
6+
7+
class SafeString {
8+
public:
9+
static std::istream & getline( std::istream & stream, std::string & line );
10+
11+
};
12+
13+
}

test/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
add_executable(dbc_test main.cpp file_loading.cpp)
1+
project(tests VERSION 0.1.0)
2+
3+
list(APPEND TEST_SOURCES main.cpp
4+
test_file_loading.cpp
5+
test_utils.cpp)
6+
7+
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/Catch2/single_include)
8+
9+
add_executable(tests ${TEST_SOURCES} ${SOURCE})
10+
11+
add_custom_target(test
12+
COMMAND ${PROJECT_NAME}
13+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
14+
DEPENDS ${PROJECT_NAME})

0 commit comments

Comments
 (0)