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

Unified Diff: utils_unittest.cc

Issue 3530011: AU: ApplyMap utility function (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: fixes for review Created 10 years, 2 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 | « utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils_unittest.cc
diff --git a/utils_unittest.cc b/utils_unittest.cc
index 3514f8a5224a42e29e91603052cbb04cb6c6a14a..a5550d38db58033afb0d82aa39449d4e8f6666aa 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -6,12 +6,14 @@
#include <sys/types.h>
#include <errno.h>
+#include <map>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "update_engine/utils.h"
+using std::map;
using std::string;
using std::vector;
@@ -183,4 +185,24 @@ TEST(UtilsTest, FuzzIntTest) {
}
}
+TEST(UtilsTest, ApplyMapTest) {
+ int initial_values[] = {1, 2, 3, 4, 6};
+ vector<int> collection(&initial_values[0],
+ initial_values + arraysize(initial_values));
+ EXPECT_EQ(arraysize(initial_values), collection.size());
+ int expected_values[] = {1, 2, 5, 4, 8};
+ map<int, int> value_map;
+ value_map[3] = 5;
+ value_map[6] = 8;
+ value_map[5] = 10;
+
+ utils::ApplyMap(&collection, value_map);
+
+ size_t index = 0;
+ for (vector<int>::iterator it = collection.begin(), e = collection.end();
+ it != e; ++it) {
+ EXPECT_EQ(expected_values[index++], *it);
+ }
+}
+
} // namespace chromeos_update_engine
« no previous file with comments | « utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698