Skip to content

Commit 72226f3

Browse files
committed
quick name change for the utils function
1 parent 7a60536 commit 72226f3

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/util/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Utils {
44

5-
std::istream & SafeString::getline( std::istream & stream, std::string & line ) {
5+
std::istream & SafeString::get_line( std::istream & stream, std::string & line ) {
66
std::string newline;
77

88
std::getline( stream, newline );

src/util/utils.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ namespace Utils {
66

77
class SafeString {
88
public:
9-
static std::istream & getline( std::istream & stream, std::string & line );
9+
/**
10+
* This is a safe non line ending specific get_ine function. This is to help with files
11+
* carried over from different systems. i.e Unix file comes to Windows with LF endings
12+
* instead of CRLF.
13+
*
14+
* @param stream [description]
15+
* @param line [description]
16+
* @return [description]
17+
*/
18+
static std::istream & get_line( std::istream & stream, std::string & line );
1019

1120
};
1221

test/test_utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
using namespace Utils;
66

7-
TEST_CASE("Basic file input with safe getline", "") {
8-
SECTION("Verify line inputs") {
7+
TEST_CASE("Basic file input with safe get_line that is non line ending specific", "") {
8+
SECTION("Verify various line ending input files") {
99
std::ifstream TextFile;
1010
std::string test;
1111

1212
TextFile.open(TEXT_FILE, std::ios::in);
1313
CHECK(TextFile.is_open());
1414

1515
if(TextFile.is_open()) {
16-
SafeString::getline(TextFile, test);
16+
SafeString::get_line(TextFile, test);
1717
REQUIRE(test == "This is a non dbc formatted file.");
18-
SafeString::getline(TextFile, test);
18+
SafeString::get_line(TextFile, test);
1919
REQUIRE(test == "");
20-
SafeString::getline(TextFile, test);
20+
SafeString::get_line(TextFile, test);
2121
REQUIRE(test == "Make sure things pass with this");
22-
SafeString::getline(TextFile, test);
22+
SafeString::get_line(TextFile, test);
2323
REQUIRE(test == "Who knows what might happen.");
2424

2525
TextFile.close();

0 commit comments

Comments
 (0)