File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -136,10 +136,8 @@ std::string concat_dir_file(
136
136
const std::string &file_name)
137
137
{
138
138
#ifdef _WIN32
139
- return (file_name.size ()>1 &&
140
- file_name[0 ]!=' /' &&
141
- file_name[1 ]!=' :' ) ?
142
- file_name : directory+" \\ " +file_name;
139
+ return (file_name.size () > 1 && file_name[0 ] != ' /' && file_name[1 ] == ' :' ) ?
140
+ file_name : directory + " \\ " + file_name;
143
141
#else
144
142
return (!file_name.empty () && file_name[0 ]==' /' ) ?
145
143
file_name : directory+" /" +file_name;
Original file line number Diff line number Diff line change @@ -14,6 +14,27 @@ Author: Daniel Kroening
14
14
15
15
#include < fstream>
16
16
17
+ TEST_CASE (" concat_dir_file functionality" , " [core][util][file_util]" )
18
+ {
19
+ temp_dirt temp_dir (" testXXXXXX" );
20
+ const std::string path = concat_dir_file (temp_dir.path , " bla.txt" );
21
+
22
+ REQUIRE (path.size () > temp_dir.path .size () + std::string (" bla.txt" ).size ());
23
+ #ifdef _WIN32
24
+ REQUIRE (path.find (' \\ ' ) != std::string::npos);
25
+ #else
26
+ REQUIRE (path.find (' /' ) != std::string::npos);
27
+ #endif
28
+
29
+ #ifdef _WIN32
30
+ const std::string qualified_path = " z:\some\path\f oo.txt" ;
31
+ #else
32
+ const std::string qualified_path = " /some/path/foo.txt" ;
33
+ #endif
34
+ const std::string path2 = concat_dir_file (temp_dir.path , qualified_path);
35
+ REQUIRE (path2 == qualified_path);
36
+ }
37
+
17
38
TEST_CASE (" is_directory functionality" , " [core][util][file_util]" )
18
39
{
19
40
temp_dirt temp_dir (" testXXXXXX" );
You can’t perform that action at this time.
0 commit comments