File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 22
33namespace 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 );
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44
55using 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 ();
You can’t perform that action at this time.
0 commit comments