Skip to content

Commit 8b06465

Browse files
committed
Add path resolution tests
1 parent 6cc4f53 commit 8b06465

6 files changed

Lines changed: 47 additions & 0 deletions

File tree

test.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,6 +2990,43 @@ static void fuzz_crash()
29902990
}
29912991
}
29922992

2993+
static void same_name()
2994+
{
2995+
const char code[] = "#include <header_a.h>\n"
2996+
"#include <header_b.h>\n"
2997+
"TEST\n";
2998+
2999+
simplecpp::DUI dui;
3000+
dui.includePaths.push_back("./testsuite/path-tests/include_a");
3001+
dui.includePaths.push_back("./testsuite/path-tests/include_b");
3002+
3003+
ASSERT_EQUALS("\n\nOK", preprocess(code, dui));
3004+
}
3005+
3006+
static void file_id()
3007+
{
3008+
const char code[] = "#include \"once.h\"\n"
3009+
"#include \"Once.h\"\n"
3010+
3011+
"#include <once.h>\n"
3012+
"#include <Once.h>\n"
3013+
3014+
"#include \"../path-tests/once.h\"\n"
3015+
"#include \"../path-tests/Once.h\"\n"
3016+
"#include \"../Path-Tests/once.h\"\n"
3017+
"#include \"../Path-Tests/Once.h\"\n"
3018+
3019+
"#include \"include_a/../once.h\"\n"
3020+
"#include \"include_a/../Once.h\"\n"
3021+
"#include \"include_A/../once.h\"\n"
3022+
"#include \"include_A/../Once.h\"\n";
3023+
3024+
simplecpp::DUI dui;
3025+
dui.includePaths.push_back("./testsuite/path-tests");
3026+
3027+
ASSERT_EQUALS("\n#line 2 \"testsuite/path-tests/once.h\"\nONCE", preprocess(code, dui));
3028+
}
3029+
29933030
int main(int argc, char **argv)
29943031
{
29953032
TEST_CASE(backslash);
@@ -3212,6 +3249,10 @@ int main(int argc, char **argv)
32123249

32133250
TEST_CASE(warning);
32143251

3252+
// path resolution
3253+
TEST_CASE(same_name);
3254+
TEST_CASE(file_id);
3255+
32153256
// utility functions.
32163257
TEST_CASE(simplifyPath);
32173258
TEST_CASE(simplifyPath_cppcheck);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "same_name.h"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define TEST E
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "same_name.h"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define TEST OK

testsuite/path-tests/once.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
ONCE

0 commit comments

Comments
 (0)