brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 9d202e4 Raw
42 lines · cpp
1//===-- DraftStoreTests.cpp -------------------------------------*- C++ -*-===//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 "DraftStore.h"10#include "gmock/gmock.h"11#include "gtest/gtest.h"12 13namespace clang {14namespace clangd {15namespace {16 17TEST(DraftStore, Versions) {18  DraftStore DS;19  Path File = "foo.cpp";20 21  EXPECT_EQ("25", DS.addDraft(File, "25", ""));22  EXPECT_EQ("25", DS.getDraft(File)->Version);23  EXPECT_EQ("", *DS.getDraft(File)->Contents);24 25  EXPECT_EQ("26", DS.addDraft(File, "", "x"));26  EXPECT_EQ("26", DS.getDraft(File)->Version);27  EXPECT_EQ("x", *DS.getDraft(File)->Contents);28 29  EXPECT_EQ("27", DS.addDraft(File, "", "x")) << "no-op change";30  EXPECT_EQ("27", DS.getDraft(File)->Version);31  EXPECT_EQ("x", *DS.getDraft(File)->Contents);32 33  // We allow versions to go backwards.34  EXPECT_EQ("7", DS.addDraft(File, "7", "y"));35  EXPECT_EQ("7", DS.getDraft(File)->Version);36  EXPECT_EQ("y", *DS.getDraft(File)->Contents);37}38 39} // namespace40} // namespace clangd41} // namespace clang42