Debian Codegraph @

clang-tools-extra/unittests/clang-doc/ClangDocTest.h

raw
1 //===-- clang-doc/ClangDocTest.h ------------------------------------------===//
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 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANG_DOC_CLANGDOCTEST_H
10 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANG_DOC_CLANGDOCTEST_H
11
12 #include "ClangDocTest.h"
13 #include "Representation.h"
14 #include "clang/AST/RecursiveASTVisitor.h"
15 #include "clang/Basic/Diagnostic.h"
16 #include "clang/Basic/DiagnosticOptions.h"
17 #include "gtest/gtest.h"
18
19 namespace clang {
20 namespace doc {
21
22 using EmittedInfoList = std::vector<std::unique_ptr<Info>>;
23
24 static const SymbolID EmptySID = SymbolID();
25 static const SymbolID NonEmptySID =
26 SymbolID{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
27
28 NamespaceInfo *InfoAsNamespace(Info *I);
29 RecordInfo *InfoAsRecord(Info *I);
30 FunctionInfo *InfoAsFunction(Info *I);
31 EnumInfo *InfoAsEnum(Info *I);
32 TypedefInfo *InfoAsTypedef(Info *I);
33
34 // Unlike the operator==, these functions explicitly does not check USRs, as
35 // that may change and it would be better to not rely on its implementation.
36 void CheckReference(Reference &Expected, Reference &Actual);
37 void CheckTypeInfo(TypeInfo *Expected, TypeInfo *Actual);
38 void CheckFieldTypeInfo(FieldTypeInfo *Expected, FieldTypeInfo *Actual);
39 void CheckMemberTypeInfo(MemberTypeInfo *Expected, MemberTypeInfo *Actual);
40
41 // This function explicitly does not check USRs, as that may change and it would
42 // be better to not rely on its implementation.
43 void CheckBaseInfo(Info *Expected, Info *Actual);
44 void CheckSymbolInfo(SymbolInfo *Expected, SymbolInfo *Actual);
45 void CheckFunctionInfo(FunctionInfo *Expected, FunctionInfo *Actual);
46 void CheckEnumInfo(EnumInfo *Expected, EnumInfo *Actual);
47 void CheckTypedefInfo(TypedefInfo *Expected, TypedefInfo *Actual);
48 void CheckNamespaceInfo(NamespaceInfo *Expected, NamespaceInfo *Actual);
49 void CheckRecordInfo(RecordInfo *Expected, RecordInfo *Actual);
50 void CheckBaseRecordInfo(BaseRecordInfo *Expected, BaseRecordInfo *Actual);
51
52 void CheckIndex(Index &Expected, Index &Actual);
53
54 class ClangDocContextTest : public ::testing::Test {
55 protected:
56 ClangDocContextTest();
57 ~ClangDocContextTest() override;
58
59 ClangDocContext
60 getClangDocContext(std::vector<std::string> UserStylesheets = {},
61 StringRef RepositoryUrl = "",
62 StringRef RepositoryLinePrefix = "", StringRef Base = "");
63
64 DiagnosticOptions DiagOpts;
65 llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
66 DiagnosticsEngine Diags;
67 };
68
69 } // namespace doc
70 } // namespace clang
71
72 #endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANG_DOC_CLANGDOCTEST_H