-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix path resolver and add debugging output #21
base: master
Are you sure you want to change the base?
Changes from all commits
f15004d
ca57f2d
fe08deb
63b3002
3ea69a0
3f811e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,10 @@ using namespace vs; | |
|
||
int test_normalizer(const char* expected, const char* parent, const char* child, bool allow_exit, bool base_dir){ | ||
auto tmp = resolve_path::normalizer(parent,child,allow_exit,base_dir); | ||
std::cout<<"╭<parent> "<<parent<<"\n"; | ||
std::cout<<"├<child> "<<child<<"\n"; | ||
std::cout<<"├> "<<tmp.second<<"\n"; | ||
std::cout<<"╰>> "<<expected<<"\n"; | ||
std::cerr<<"╭<parent> "<<parent<<"\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we discussed this change. If I manage to fix the resolver, I'll revert these changes before merging. |
||
std::cerr<<"├<child> "<<child<<"\n"; | ||
std::cerr<<"├> "<<tmp.second<<"\n"; | ||
std::cerr<<"╰>> "<<expected<<"\n"; | ||
//if(!tmp.first)return 1; | ||
if(tmp.second==expected){return 0;} | ||
else{ | ||
|
@@ -26,10 +26,11 @@ int main(){ | |
ret+=test_normalizer("/quick-js/ww/a", "/hello world/banana/", "./../.././quick-js/ww/a", true, false); | ||
ret+=test_normalizer("", "/hello world/banana/", "../../quick-js/ww/a", false, false); | ||
ret+=test_normalizer("", "/hello world/banana/", "./../.././quick-js/ww/a", false, false); | ||
ret+=test_normalizer("/hello world/banana/ww/a", "/hello world/banana/", "quick-js/../quick-js/ww/a", false, false); | ||
ret+=test_normalizer("/hello world/banana/quick-js/ww/a", "/hello world/banana/", "quick-js/../quick-js/ww/a", false, false); | ||
ret+=test_normalizer("/hello world/banana/ww/a", "/hello world/banana/", "quick-js/./.././ww/a", false, false); | ||
ret+=test_normalizer("/a/b../", "/a/", "b../", false, false); | ||
|
||
assert(ret=0); | ||
std::cerr<<"ret = "<<ret<<"\n"; | ||
assert(ret==0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes where the test fails even when ret is eq to 0 ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOL in theory my IDE should have warned me, somehow I missed its message. |
||
return 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so this you might laugh at this. ;) Something just didn't feel right about using "3" here.
In my own code, I might
#define DOUBLE_DOT_DIR_SEP "../"
or something at the top, then just use that string... and then usingsizeof
would seem more appropriate, but that too seems like overkill.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is totally fine, hardcoded numbers are just bad. That is resolved at compile time so it is not like it reduces performance or anything.
For context, in modern C++ one would define a constexpr value in place of a define if it had to be made more explicit. But it is fine as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Maybe @Jammyjamjamman is right and I'm not a bad developer! :)