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 |