1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/sync_file_system/subtree_set.h"
6
7#include "testing/gtest/include/gtest/gtest.h"
8
9#define FPL(path) base::FilePath(FILE_PATH_LITERAL(path))
10
11namespace sync_file_system {
12
13TEST(SubtreeSetTest, InsertAndErase) {
14  SubtreeSet subtrees;
15
16  EXPECT_EQ(0u, subtrees.size());
17  EXPECT_TRUE(subtrees.insert(FPL("/a/b/c")));
18  EXPECT_FALSE(subtrees.insert(FPL("/a/b")));
19  EXPECT_FALSE(subtrees.insert(FPL("/a/b/c")));
20  EXPECT_FALSE(subtrees.insert(FPL("/a/b/c/d")));
21  EXPECT_TRUE(subtrees.insert(FPL("/a/b/d")));
22  EXPECT_FALSE(subtrees.insert(FPL("/")));
23
24  EXPECT_EQ(2u, subtrees.size());
25
26  EXPECT_FALSE(subtrees.erase(FPL("/")));
27  EXPECT_FALSE(subtrees.erase(FPL("/a")));
28  EXPECT_TRUE(subtrees.erase(FPL("/a/b/c")));
29
30  EXPECT_EQ(1u, subtrees.size());
31
32  EXPECT_TRUE(subtrees.insert(FPL("/a/b/c/d")));
33
34  EXPECT_EQ(2u, subtrees.size());
35}
36
37}  // namespace sync_file_system
38