diff options
Diffstat (limited to 'unittests/Tooling/LookupTest.cpp')
-rw-r--r-- | unittests/Tooling/LookupTest.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/unittests/Tooling/LookupTest.cpp b/unittests/Tooling/LookupTest.cpp index f42f31e9dd99..a08b2b418f7b 100644 --- a/unittests/Tooling/LookupTest.cpp +++ b/unittests/Tooling/LookupTest.cpp @@ -68,7 +68,7 @@ TEST(LookupTest, replaceNestedFunctionName) { "namespace b { void f() { a::foo(); } }\n"); Visitor.OnCall = [&](CallExpr *Expr) { - EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar")); + EXPECT_EQ("::a::bar", replaceCallExpr(Expr, "::a::bar")); }; Visitor.runOver("namespace a { void foo(); }\n" "namespace b { namespace a { void foo(); }\n" @@ -127,6 +127,38 @@ TEST(LookupTest, replaceNestedFunctionName) { "namespace a { namespace b { namespace c {" "void f() { foo(); }" "} } }\n"); + + // If the shortest name is ambiguous, we need to add more qualifiers. + Visitor.OnCall = [&](CallExpr *Expr) { + EXPECT_EQ("::a::y::bar", replaceCallExpr(Expr, "::a::y::bar")); + }; + Visitor.runOver(R"( + namespace a { + namespace b { + namespace x { void foo() {} } + namespace y { void foo() {} } + } + } + + namespace a { + namespace b { + void f() { x::foo(); } + } + })"); + + Visitor.OnCall = [&](CallExpr *Expr) { + EXPECT_EQ("y::bar", replaceCallExpr(Expr, "::y::bar")); + }; + Visitor.runOver(R"( + namespace a { + namespace b { + namespace x { void foo() {} } + namespace y { void foo() {} } + } + } + + void f() { a::b::x::foo(); } + )"); } TEST(LookupTest, replaceNestedClassName) { |