1 //===-- DraftStoreTests.cpp -------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "DraftStore.h"
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
17 TEST(DraftStore
, Versions
) {
19 Path File
= "foo.cpp";
21 EXPECT_EQ("25", DS
.addDraft(File
, "25", ""));
22 EXPECT_EQ("25", DS
.getDraft(File
)->Version
);
23 EXPECT_EQ("", *DS
.getDraft(File
)->Contents
);
25 EXPECT_EQ("26", DS
.addDraft(File
, "", "x"));
26 EXPECT_EQ("26", DS
.getDraft(File
)->Version
);
27 EXPECT_EQ("x", *DS
.getDraft(File
)->Contents
);
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
);
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
);