Skip to content

Commit 2a28f9a

Browse files
author
Dilawar Singh
committed
Added tests to normalizepath.
1 parent 4c2086a commit 2a28f9a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

basecode/global.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ string normalizePath(const string& path)
265265
string s(path);
266266
static std::regex e0("/+"); // Remove multiple / by single /
267267
s = std::regex_replace(s, e0, "/");
268-
static std::regex e1("(/\\./)+"); // Remove multiple / by single /
268+
static std::regex e1("/(\\./)+"); // Remove multiple / by single /
269269
s = std::regex_replace(s, e1, "/");
270270
return s;
271271
}

basecode/testGlobals.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
*/
99

1010
#include "global.h"
11+
#include "../utility/simple_assert.hpp"
1112

1213
void test_normalize_path()
1314
{
1415
string p1("//a/./b");
1516
auto p1fixes = moose::normalizePath(p1);
16-
cout << p1 << " fixed " << p1fixes << endl;
17+
std::cout << p1 << " " << p1fixes << std::endl;
18+
19+
string p2("//a/./././///b");
20+
auto p2fixes = moose::normalizePath(p2);
21+
std::cout << p2 << " " << p2fixes << std::endl;
22+
SIMPLE_ASSERT( p2fixes == "/a/b");
1723
}
1824

1925
int main(int argc, const char *argv[])

0 commit comments

Comments
 (0)