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

Unified Diff: tools/gn/pointer_set_unittest.cc

Issue 1494883002: GN: Makes GN output deterministic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/pointer_set_unittest.cc
diff --git a/tools/gn/pointer_set_unittest.cc b/tools/gn/pointer_set_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..299d36ee5738247d4a4f80685c80effc76726b94
--- /dev/null
+++ b/tools/gn/pointer_set_unittest.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
mithro-old 2015/12/03 05:20:31 You could probably use a bunch more tests here. D
Zachary Forman 2015/12/03 07:27:02 I've refactored so that we should be as safe as a
+
+#include <string>
+#include <vector>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/pointer_set.h"
+
+TEST(PointerSet, Sorted) {
+ std::vector<int> vals{1, 55, 3};
+ PointerSet<int> ps;
+ ps.insert(&vals[0]);
+ ps.insert(&vals[1]);
+ ps.insert(&vals[2]);
+ EXPECT_EQ(1, **ps.begin());
mithro-old 2015/12/03 05:20:31 These EXPECT_EQs are kind of hard to read. There
Zachary Forman 2015/12/03 07:27:02 Acknowledged. Entire set of tests is dead now anyw
+ EXPECT_EQ(55, **(--ps.end()));
+ EXPECT_EQ(&vals[0], *ps.begin());
+ EXPECT_EQ(&vals[1], *(--ps.end()));
+}
+
+TEST(PointerSet, RangeInsertion) {
+ std::vector<std::string> vals{"abc", "zzz", "cab", "abb", "xyz", "lmn"};
+ std::vector<std::string*> ptrs;
+ for (size_t i = 0; i < vals.size(); i++) {
+ ptrs.push_back(&vals[i]);
+ }
+ PointerSet<std::string> ps(ptrs.begin(), ptrs.end());
+ EXPECT_EQ(6ul, ps.size());
+ EXPECT_EQ(&vals[3], *ps.begin());
+}

Powered by Google App Engine
This is Rietveld 408576698