Debian Codegraph @

clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

raw
1 //===-- clang-doc/HTMLGeneratorTest.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 "ClangDocTest.h"
10 #include "Generators.h"
11 #include "Representation.h"
12 #include "config.h"
13 #include "support/Utils.h"
14 #include "clang/Basic/Version.h"
15 #include "llvm/Testing/Support/Error.h"
16 #include "gmock/gmock.h"
17 #include "gtest/gtest.h"
18
19 using namespace llvm;
20 using namespace testing;
21 using namespace clang;
22 using namespace clang::doc;
23
24 static const std::string ClangDocVersion = getClangToolFullVersion("clang-doc");
25
26 static std::unique_ptr<Generator> getHTMLGenerator() {
27 auto G = findGeneratorByName("html");
28 if (!G)
29 return nullptr;
30 return std::move(G.get());
31 }
32
33 class HTMLGeneratorTest : public ClangDocContextTest {
34 protected:
35 ClangDocContext
36 getClangDocContext(std::vector<std::string> UserStylesheets = {},
37 StringRef RepositoryUrl = "",
38 StringRef RepositoryLinePrefix = "", StringRef Base = "") {
39 ClangDocContext CDCtx{nullptr,
40 "test-project",
41 false,
42 "",
43 "",
44 RepositoryUrl,
45 RepositoryLinePrefix,
46 Base,
47 UserStylesheets,
48 Diags,
49 false};
50 CDCtx.UserStylesheets.insert(
51 CDCtx.UserStylesheets.begin(),
52 "../share/clang/clang-doc-default-stylesheet.css");
53 CDCtx.JsScripts.emplace_back("index.js");
54 return CDCtx;
55 }
56 };
57
58 TEST_F(HTMLGeneratorTest, createResources) {
59 auto G = getHTMLGenerator();
60 ASSERT_THAT(G, NotNull()) << "Could not find HTMLGenerator";
61 ClangDocContext CDCtx = getClangDocContext();
62 EXPECT_THAT_ERROR(G->createResources(CDCtx), Failed())
63 << "Empty UserStylesheets or JsScripts should fail!";
64 }