Add window.gc back to Smoothness.WillNavigateToPageHook
[chromium-blink-merge.git] / tools / gn / unique_vector_unittest.cc
blob0f5d461b04d38f32dbe3b3c35be5918e4f17bc89
1 // Copyright (c) 2013 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.
5 #include <algorithm>
7 #include "base/time/time.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/unique_vector.h"
11 TEST(UniqueVector, PushBack) {
12 UniqueVector<int> foo;
13 EXPECT_TRUE(foo.push_back(1));
14 EXPECT_FALSE(foo.push_back(1));
15 EXPECT_TRUE(foo.push_back(2));
16 EXPECT_TRUE(foo.push_back(0));
17 EXPECT_FALSE(foo.push_back(2));
18 EXPECT_FALSE(foo.push_back(1));
20 EXPECT_EQ(3u, foo.size());
21 EXPECT_EQ(1, foo[0]);
22 EXPECT_EQ(2, foo[1]);
23 EXPECT_EQ(0, foo[2]);
25 // Verify those results with IndexOf as well.
26 EXPECT_EQ(0u, foo.IndexOf(1));
27 EXPECT_EQ(1u, foo.IndexOf(2));
28 EXPECT_EQ(2u, foo.IndexOf(0));
29 EXPECT_EQ(static_cast<size_t>(-1), foo.IndexOf(99));
32 TEST(UniqueVector, PushBackViaSwap) {
33 UniqueVector<std::string> vect;
34 std::string a("a");
35 EXPECT_TRUE(vect.PushBackViaSwap(&a));
36 EXPECT_EQ("", a);
38 a = "a";
39 EXPECT_FALSE(vect.PushBackViaSwap(&a));
40 EXPECT_EQ("a", a);
42 EXPECT_EQ(0u, vect.IndexOf("a"));