|
|
@@ -61,11 +61,51 @@ public:
|
|
|
TS_ASSERT_EQUALS(obj[0][1], 6);
|
|
|
}
|
|
|
|
|
|
- void test_map_vector_map_iterator() {
|
|
|
+ void test_map_vector_map_iterator_matches_size() {
|
|
|
std::map<int, std::vector<std::map<int, int>>> const obj{{1, {{{1, 1}, {2, 2}}}}};
|
|
|
std::vector<std::tuple<int, int, int>> const expected{{1, 1, 1}, {1, 2, 2}};
|
|
|
auto rit = make_recursive_iterator(obj);
|
|
|
decltype(rit) end{ };
|
|
|
TS_ASSERT_EQUALS(std::distance(rit, end), expected.size());
|
|
|
}
|
|
|
+
|
|
|
+ void test_map_vector_map_iterator_matches_data() {
|
|
|
+ std::map<int, std::vector<std::map<int, int>>> const obj{{1, {{{1, 1}, {2, 2}}}}};
|
|
|
+ std::vector<std::tuple<int, int, int>> const expected{{1, 1, 1}, {1, 2, 2}};
|
|
|
+ auto rit = make_recursive_iterator(obj);
|
|
|
+ for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
|
|
|
+ TS_ASSERT_EQUALS(*it, *rit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void test_map_vector_map_iterator_can_edit_data() {
|
|
|
+ std::map<int, std::vector<std::map<int, int>>> obj{{1, {{{1, 1}, {2, 2}}}}};
|
|
|
+ auto rit = make_recursive_iterator(obj);
|
|
|
+ std::get<2>(*rit) = 4;
|
|
|
+ TS_ASSERT_EQUALS(obj[1][0][1], 4);
|
|
|
+ }
|
|
|
+
|
|
|
+ void test_vector_map_vector_iterator_matches_size() {
|
|
|
+ std::vector<std::map<int, std::vector<int>>> const obj{{{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
|
|
|
+ std::vector<std::tuple<int, int>> const expected{{1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}, {1, 3}, {1, 4}};
|
|
|
+ auto rit = make_recursive_iterator(obj);
|
|
|
+ decltype(rit) end{ };
|
|
|
+ TS_ASSERT_EQUALS(std::distance(rit, end), expected.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ void test_vector_map_vector_iterator_matches_data() {
|
|
|
+ std::vector<std::map<int, std::vector<int>>> const obj{{{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
|
|
|
+ std::vector<std::tuple<int, int>> const expected{{1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}, {1, 3}, {1, 4}};
|
|
|
+ auto rit = make_recursive_iterator(obj);
|
|
|
+ for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
|
|
|
+ TS_ASSERT_EQUALS(*it, *rit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void test_vector_map_vector_iterator_can_edit_data() {
|
|
|
+ std::vector<std::map<int, std::vector<int>>> obj{{{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
|
|
|
+ auto rit = make_recursive_iterator(obj);
|
|
|
+ std::get<1>(*rit) = 6;
|
|
|
+ TS_ASSERT_EQUALS(obj[0][1][0], 6);
|
|
|
+ }
|
|
|
};
|