Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: base/stl_util_unittest.cc

Issue 11415239: Add STLSetDifference to stl_util.h, because std::set_difference is extremely (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/stl_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 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 <set>
6
7 #include "base/stl_util.h"
willchan no longer on Chromium 2012/12/05 18:27:40 Should go first, as per style guide example of bas
not at google - send to devlin 2012/12/05 18:36:01 done, I think. I couldn't find basictypes_unittest
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace base {
11 namespace {
12
13 TEST(STLUtilTest, STLIsSorted) {
14 {
15 std::set<int> set;
16 set.insert(24);
17 set.insert(1);
18 set.insert(12);
19 EXPECT_TRUE(STLIsSorted(set));
20 }
21
22 {
23 std::vector<int> vector;
24 vector.push_back(1);
25 vector.push_back(1);
26 vector.push_back(4);
27 vector.push_back(64);
28 vector.push_back(12432);
29 EXPECT_TRUE(STLIsSorted(vector));
30 vector.back() = 1;
31 EXPECT_FALSE(STLIsSorted(vector));
32 }
33 }
34
35 TEST(STLUtilTest, STLSetDifference) {
36 std::set<int> a1;
37 a1.insert(1);
38 a1.insert(2);
39 a1.insert(3);
40 a1.insert(4);
41
42 std::set<int> a2;
43 a2.insert(3);
44 a2.insert(4);
45 a2.insert(5);
46 a2.insert(6);
47 a2.insert(7);
48
49 {
50 std::set<int> difference;
51 difference.insert(1);
52 difference.insert(2);
53 EXPECT_EQ(difference, STLSetDifference<std::set<int> >(a1, a2));
54 }
55
56 {
57 std::set<int> difference;
58 difference.insert(5);
59 difference.insert(6);
60 difference.insert(7);
61 EXPECT_EQ(difference, STLSetDifference<std::set<int> >(a2, a1));
62 }
63
64 {
65 std::vector<int> difference;
66 difference.push_back(1);
67 difference.push_back(2);
68 EXPECT_EQ(difference, STLSetDifference<std::vector<int> >(a1, a2));
69 }
70
71 {
72 std::vector<int> difference;
73 difference.push_back(5);
74 difference.push_back(6);
75 difference.push_back(7);
76 EXPECT_EQ(difference, STLSetDifference<std::vector<int> >(a2, a1));
77 }
78 }
79
80 } // namespace
81 } // namespace base
OLDNEW
« no previous file with comments | « base/stl_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698