12#include "gmock/gmock.h"
13#include "gtest/gtest.h"
23class TestCache :
public FileCache {
25 mutable std::string Value;
28 TestCache() : FileCache(
testPath(
"foo.cc")) {}
30 void setContents(
const char *
C) {
37 std::pair<std::string,
bool>
38 get(std::chrono::steady_clock::time_point FreshTime)
const {
39 bool GotParse =
false;
44 [&](std::optional<llvm::StringRef> Data) {
46 Value = Data.value_or(
"").str();
53 return {Result, GotParse};
60TEST(FileCacheTest, Invalidation) {
63 auto StaleOK = std::chrono::steady_clock::now();
64 auto MustBeFresh = StaleOK + std::chrono::hours(1);
67 EXPECT_THAT(
C.get(StaleOK), Parsed(
"a")) <<
"Parsed first time";
68 EXPECT_THAT(
C.get(StaleOK), Cached(
"a")) <<
"Cached (time)";
69 EXPECT_THAT(
C.get(MustBeFresh), Cached(
"a")) <<
"Cached (stat)";
71 EXPECT_THAT(
C.get(StaleOK), Cached(
"a")) <<
"Cached (time)";
72 EXPECT_THAT(
C.get(MustBeFresh), Parsed(
"bb")) <<
"Size changed";
73 EXPECT_THAT(
C.get(MustBeFresh), Cached(
"bb")) <<
"Cached (stat)";
74 C.setContents(
nullptr);
75 EXPECT_THAT(
C.get(StaleOK), Cached(
"bb")) <<
"Cached (time)";
76 EXPECT_THAT(
C.get(MustBeFresh), Parsed(
"")) <<
"stat failed";
77 EXPECT_THAT(
C.get(MustBeFresh), Cached(
"")) <<
"Cached (404)";
79 EXPECT_THAT(
C.get(StaleOK), Cached(
"")) <<
"Cached (time)";
80 EXPECT_THAT(
C.get(MustBeFresh), Parsed(
"bb")) <<
"Size changed";
MATCHER_P(diagMessage, M, "")
std::string testPath(PathRef File, llvm::sys::path::Style Style)
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//