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

Unified Diff: tools/gn/runtime_deps_unittest.cc

Issue 2938163003: Use ContainsValue() instead of std::find() in tools/ (Closed)
Patch Set: Fixing build error. Created 3 years, 6 months 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
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/target.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/runtime_deps_unittest.cc
diff --git a/tools/gn/runtime_deps_unittest.cc b/tools/gn/runtime_deps_unittest.cc
index d0658f4410516aa31db4c59ae77f914947e92604..7de91fc1b0c9c6e652fa5fd06c6623c6c0edc387 100644
--- a/tools/gn/runtime_deps_unittest.cc
+++ b/tools/gn/runtime_deps_unittest.cc
@@ -4,8 +4,7 @@
#include <stddef.h>
-#include <algorithm>
-
+#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/runtime_deps.h"
#include "tools/gn/scheduler.h"
@@ -91,29 +90,25 @@ TEST(RuntimeDeps, Libs) {
EXPECT_TRUE(MakePair("./main", &main) == result[0]);
// The rest of the ordering is undefined. First the data files.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../stat.dat", &stat)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../shared.dat", &shared)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../loadable.dat", &loadable)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../set.dat", &set)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../main.dat", &main)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../stat.dat", &stat)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../shared.dat", &shared)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../loadable.dat", &loadable)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../set.dat", &set)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../main.dat", &main)))
+ << GetVectorDescription(result);
// Check the static library and loadable module.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("./libshared.so", &shared)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("./libloadable.so", &loadable)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("./libshared.so", &shared)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("./libloadable.so", &loadable)))
+ << GetVectorDescription(result);
}
// Tests that executables that aren't listed as data deps aren't included in
@@ -163,12 +158,11 @@ TEST(RuntimeDeps, ExeDataDep) {
EXPECT_TRUE(MakePair("./main", &main) == result[0]);
// The rest of the ordering is undefined.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("./datadep", &datadep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../final_in.dat", &final_in)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("./datadep", &datadep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../final_in.dat", &final_in)))
+ << GetVectorDescription(result);
}
// Tests that action and copy outputs are considered if they're data deps, but
@@ -232,24 +226,23 @@ TEST(RuntimeDeps, ActionOutputs) {
EXPECT_TRUE(MakePair("./main", &main) == result[0]);
// The rest of the ordering is undefined.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../datadep.data", &datadep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../datadep_copy.data", &datadep_copy)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../datadep.output", &datadep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../datadep_copy.output", &datadep_copy)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../dep.data", &dep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../dep_copy/data/", &dep_copy)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../datadep.data", &datadep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(
+ result, MakePair("../../datadep_copy.data", &datadep_copy)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../datadep.output", &datadep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(
+ result, MakePair("../../datadep_copy.output", &datadep_copy)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../dep.data", &dep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../dep_copy/data/", &dep_copy)))
+ << GetVectorDescription(result);
// Explicitly asking for the runtime deps of an action target only includes
// the data and not all outputs.
@@ -344,19 +337,16 @@ TEST(RuntimeDeps, CreateBundle) {
// The rest of the ordering is undefined.
// The framework bundle's internal dependencies should not be incldued.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("Bundle.framework/", &bundle)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("Bundle.framework/", &bundle)))
+ << GetVectorDescription(result);
// But direct data and data dependencies should be.
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("./datadep", &data_dep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../dd.data", &data_dep)) !=
- result.end()) << GetVectorDescription(result);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../b.data", &bundle)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("./datadep", &data_dep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../dd.data", &data_dep)))
+ << GetVectorDescription(result);
+ EXPECT_TRUE(base::ContainsValue(result, MakePair("../../b.data", &bundle)))
+ << GetVectorDescription(result);
}
// Tests that a dependency duplicated in regular and data deps is processed
@@ -380,9 +370,9 @@ TEST(RuntimeDeps, Dupe) {
// The results should be the executable and the copy output.
std::vector<std::pair<OutputFile, const Target*>> result =
ComputeRuntimeDeps(&target);
- EXPECT_TRUE(std::find(result.begin(), result.end(),
- MakePair("../../action.output", &action)) !=
- result.end()) << GetVectorDescription(result);
+ EXPECT_TRUE(
+ base::ContainsValue(result, MakePair("../../action.output", &action)))
+ << GetVectorDescription(result);
}
// Tests that actions can't have output substitutions.
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698