56 lines · cpp
1//===-- clang-doc/HTMLMustacheGeneratorTest.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-exception6//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 19using namespace llvm;20using namespace testing;21using namespace clang;22using namespace clang::doc;23 24// FIXME: Don't enable unit tests that can read files. Remove once we can use25// lit to test these properties.26#define ENABLE_LOCAL_TEST 027 28static const std::string ClangDocVersion = getClangToolFullVersion("clang-doc");29 30static std::unique_ptr<Generator> getHTMLMustacheGenerator() {31 auto G = findGeneratorByName("mustache");32 if (!G)33 return nullptr;34 return std::move(G.get());35}36 37static ClangDocContext38getClangDocContext(std::vector<std::string> UserStylesheets = {},39 StringRef RepositoryUrl = "",40 StringRef RepositoryLinePrefix = "", StringRef Base = "") {41 ClangDocContext CDCtx{42 {}, "test-project", {}, {}, {}, RepositoryUrl, RepositoryLinePrefix,43 Base, UserStylesheets};44 CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), "");45 CDCtx.JsScripts.emplace_back("");46 return CDCtx;47}48 49TEST(HTMLMustacheGeneratorTest, createResources) {50 auto G = getHTMLMustacheGenerator();51 ASSERT_THAT(G, NotNull()) << "Could not find HTMLMustacheGenerator";52 ClangDocContext CDCtx = getClangDocContext();53 EXPECT_THAT_ERROR(G->createResources(CDCtx), Failed())54 << "Empty UserStylesheets or JsScripts should fail!";55}56