Skip to content

Commit

Permalink
[clang-doc] Add missing check in tests
Browse files Browse the repository at this point in the history
Path is now checked when comparing two Infos in the unit tests.

Differential Revision: https://reviews.llvm.org/D66124

llvm-svn: 368912
  • Loading branch information
DiegoAstiazaran committed Aug 14, 2019
1 parent b4aebff commit 6169a73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions clang-tools-extra/clang-doc/Representation.h
Expand Up @@ -238,6 +238,8 @@ struct Info {
Info(InfoType IT, SymbolID USR) : USR(USR), IT(IT) {}
Info(InfoType IT, SymbolID USR, StringRef Name)
: USR(USR), IT(IT), Name(Name) {}
Info(InfoType IT, SymbolID USR, StringRef Name, StringRef Path)
: USR(USR), IT(IT), Name(Name), Path(Path) {}
Info(const Info &Other) = delete;
Info(Info &&Other) = default;

Expand Down Expand Up @@ -269,6 +271,8 @@ struct NamespaceInfo : public Info {
NamespaceInfo(SymbolID USR) : Info(InfoType::IT_namespace, USR) {}
NamespaceInfo(SymbolID USR, StringRef Name)
: Info(InfoType::IT_namespace, USR, Name) {}
NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path)
: Info(InfoType::IT_namespace, USR, Name, Path) {}

void merge(NamespaceInfo &&I);

Expand All @@ -287,6 +291,7 @@ struct SymbolInfo : public Info {
SymbolInfo(InfoType IT) : Info(IT) {}
SymbolInfo(InfoType IT, SymbolID USR) : Info(IT, USR) {}
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name) : Info(IT, USR, Name) {}
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name, StringRef Path) : Info(IT, USR, Name, Path) {}

void merge(SymbolInfo &&I);

Expand Down Expand Up @@ -318,6 +323,8 @@ struct RecordInfo : public SymbolInfo {
RecordInfo(SymbolID USR) : SymbolInfo(InfoType::IT_record, USR) {}
RecordInfo(SymbolID USR, StringRef Name)
: SymbolInfo(InfoType::IT_record, USR, Name) {}
RecordInfo(SymbolID USR, StringRef Name, StringRef Path)
: SymbolInfo(InfoType::IT_record, USR, Name, Path) {}

void merge(RecordInfo &&I);

Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
Expand Up @@ -83,6 +83,7 @@ void CheckMemberTypeInfo(MemberTypeInfo *Expected, MemberTypeInfo *Actual) {
void CheckBaseInfo(Info *Expected, Info *Actual) {
EXPECT_EQ(size_t(20), Actual->USR.size());
EXPECT_EQ(Expected->Name, Actual->Name);
EXPECT_EQ(Expected->Path, Actual->Path);
ASSERT_EQ(Expected->Namespace.size(), Actual->Namespace.size());
for (size_t Idx = 0; Idx < Actual->Namespace.size(); ++Idx)
CheckReference(Expected->Namespace[Idx], Actual->Namespace[Idx]);
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
Expand Up @@ -91,7 +91,7 @@ TEST(SerializeTest, emitNamespaceInfo) {
CheckNamespaceInfo(&ExpectedA, A);

NamespaceInfo *B = InfoAsNamespace(Infos[2].get());
NamespaceInfo ExpectedB(EmptySID, "B");
NamespaceInfo ExpectedB(EmptySID, /*Name=*/"B", /*Path=*/"A");
ExpectedB.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
CheckNamespaceInfo(&ExpectedB, B);

Expand Down Expand Up @@ -276,7 +276,7 @@ TEST(SerializeTest, emitInternalRecordInfo) {
CheckRecordInfo(&ExpectedE, E);

RecordInfo *G = InfoAsRecord(Infos[2].get());
RecordInfo ExpectedG(EmptySID, "G");
RecordInfo ExpectedG(EmptySID, /*Name=*/"G", /*Path=*/"E");
ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedG.TagType = TagTypeKind::TTK_Class;
ExpectedG.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
Expand Down

0 comments on commit 6169a73

Please sign in to comment.