| 1 |
//===- unittests/Analysis/Scalable/EntityNameTest.cpp --------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "clang/Analysis/Scalable/Model/EntityName.h" |
| 10 |
#include "clang/Analysis/Scalable/Model/BuildNamespace.h" |
| 11 |
#include "gtest/gtest.h" |
| 12 |
|
| 13 |
namespace clang::ssaf { |
| 14 |
namespace { |
| 15 |
|
| 16 |
TEST(EntityNameTest, Equality) { |
| 17 |
auto NBN1 = NestedBuildNamespace::makeCompilationUnit("test.cpp"); |
| 18 |
auto NBN2 = NestedBuildNamespace::makeCompilationUnit("test.cpp"); |
| 19 |
|
| 20 |
EntityName EN1("c:@F@foo", "", NBN1); |
| 21 |
EntityName EN2("c:@F@foo", "", NBN2); |
| 22 |
EntityName EN3("c:@F@bar", "", NBN1); |
| 23 |
|
| 24 |
EXPECT_EQ(EN1, EN2); |
| 25 |
EXPECT_NE(EN1, EN3); |
| 26 |
} |
| 27 |
|
| 28 |
TEST(EntityNameTest, EqualityWithDifferentSuffix) { |
| 29 |
auto NBN = NestedBuildNamespace::makeCompilationUnit("test.cpp"); |
| 30 |
|
| 31 |
EntityName EN1("c:@F@foo", "1", NBN); |
| 32 |
EntityName EN2("c:@F@foo", "2", NBN); |
| 33 |
|
| 34 |
EXPECT_NE(EN1, EN2); |
| 35 |
} |
| 36 |
|
| 37 |
TEST(EntityNameTest, EqualityWithDifferentNamespace) { |
| 38 |
auto NBN1 = NestedBuildNamespace::makeCompilationUnit("test1.cpp"); |
| 39 |
auto NBN2 = NestedBuildNamespace::makeCompilationUnit("test2.cpp"); |
| 40 |
|
| 41 |
EntityName EN1("c:@F@foo", "", NBN1); |
| 42 |
EntityName EN2("c:@F@foo", "", NBN2); |
| 43 |
|
| 44 |
EXPECT_NE(EN1, EN2); |
| 45 |
} |
| 46 |
|
| 47 |
TEST(EntityNameTest, MakeQualified) { |
| 48 |
auto NBN1 = NestedBuildNamespace::makeCompilationUnit("test.cpp"); |
| 49 |
EntityName EN("c:@F@foo", "", NBN1); |
| 50 |
|
| 51 |
BuildNamespace LinkNS(BuildNamespaceKind::LinkUnit, "app"); |
| 52 |
NestedBuildNamespace NBN2(LinkNS); |
| 53 |
|
| 54 |
auto Qualified = EN.makeQualified(NBN2); |
| 55 |
|
| 56 |
EXPECT_NE(Qualified, EN); |
| 57 |
} |
| 58 |
|
| 59 |
} // namespace |
| 60 |
} // namespace clang::ssaf |