11
11
#include " ../Utilities.hpp"
12
12
13
13
#include < clocale>
14
+ #include < QUrl>
14
15
15
16
using openstudio::toPath;
16
17
using openstudio::toQString;
@@ -113,3 +114,35 @@ TEST_F(ModelEditorFixture, Path_Conversions) {
113
114
EXPECT_EQ (t, std::string (toQString (toString (p)).toUtf8 ()));
114
115
EXPECT_EQ (t, toString (toPath (toQString (toString (p)))));
115
116
}
117
+
118
+ TEST_F (ModelEditorFixture, MorePath_Conversions) {
119
+ struct PathTestCase
120
+ {
121
+ std::string inputPath;
122
+ QString expectedPath;
123
+ QString expectedUrl;
124
+ };
125
+
126
+ std::vector<PathTestCase> testCases = {
127
+ {" C:\\ Users\\ Test\\ eplustbl.html" , " C:/Users/Test/eplustbl.html" , " file:///C:/Users/Test/eplustbl.html" },
128
+ {" C:/Users/Test/eplustbl.html" , " C:/Users/Test/eplustbl.html" , " file:///C:/Users/Test/eplustbl.html" },
129
+ {" C:\\ Users/Test/eplustbl.html" , " C:/Users/Test/eplustbl.html" , " file:///C:/Users/Test/eplustbl.html" },
130
+ {" C:\\ Users\\ Test# ^\\ eplustbl.html" , " C:/Users/Test# ^/eplustbl.html" , " file:///C:/Users/Test%23%20%5E/eplustbl.html" },
131
+ {" /home/Test/eplustbl.html" , " /home/Test/eplustbl.html" , " file:///home/Test/eplustbl.html" },
132
+ {" /home/Test# ^/eplustbl.html" , " /home/Test# ^/eplustbl.html" , " file:///home/Test%23%20%5E/eplustbl.html" },
133
+ };
134
+
135
+ // double check the conversions in openstudio_lib/ResultsTabView.cpp
136
+ for (const auto & testCase : testCases) {
137
+ openstudio::path osPath = toPath (testCase.inputPath );
138
+ QString qPath = toQString (osPath);
139
+ EXPECT_EQ (qPath, testCase.expectedPath );
140
+ QUrl url = QUrl::fromLocalFile (qPath);
141
+ EXPECT_EQ (url.toString (QUrl::FullyEncoded), testCase.expectedUrl );
142
+
143
+ std::cout << " Input: " << testCase.inputPath << " , "
144
+ << " OS Path: " << osPath << " , "
145
+ << " QPath: " << qPath.toStdString () << " , "
146
+ << " Url: " << url.toString ().toStdString () << std::endl;
147
+ }
148
+ }
0 commit comments