unit-testsuites.cpp: fix hangup if file not found
If run from the wrong directory, std::ifstream f("test/data/big-list-of-naughty-strings/blns.json"); will not find the file and thus f.eof() will never return true.
Use canonical C++ file reading loop from https://gehrcke.de/2011/06/reading-files-in-c-using-ifstream-dealing-correctly-with-badbit-failbit-eofbit-and-perror/ instead.
			
			
This commit is contained in:
		
							parent
							
								
									680a4ab672
								
							
						
					
					
						commit
						8c1387cfb3
					
				
					 1 changed files with 3 additions and 5 deletions
				
			
		|  | @ -1346,13 +1346,11 @@ TEST_CASE("Big List of Naughty Strings") | |||
|     SECTION("roundtripping") | ||||
|     { | ||||
|         std::ifstream f("test/data/big-list-of-naughty-strings/blns.json"); | ||||
| 
 | ||||
|         while (not f.eof()) | ||||
|         { | ||||
|             // read line
 | ||||
|         std::string line; | ||||
|             getline(f, line); | ||||
| 
 | ||||
|         // read lines one by one, bail out on error or eof
 | ||||
|         while (getline(f, line)) | ||||
|         { | ||||
|             // trim whitespace
 | ||||
|             line = trim(line); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue