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

Side by Side Diff: mojo/public/cpp/bindings/tests/iterator_util_unittest.cc

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <algorithm>
6
7 #include "gtest/gtest.h"
8 #include "mojo/public/cpp/bindings/lib/iterator_util.h"
9 #include "mojo/public/cpp/bindings/map.h"
10 #include "mojo/public/cpp/bindings/tests/iterator_test_util.h"
11
12 namespace mojo {
13 namespace test {
14
15 using internal::MapKeyIterator;
16 using internal::MapValueIterator;
17
18 TEST(MapIteratorTest, KeyIterator) {
19 Map<int, int> my_map;
20 my_map[1] = 2;
21 my_map[3] = 4;
22 my_map[5] = 6;
23
24 MapKeyIterator<int, int> key_iter(&my_map);
25 std::vector<int> expected_vals;
26 expected_vals.push_back(1);
27 expected_vals.push_back(3);
28 expected_vals.push_back(5);
29 ExpectIteratorValues(key_iter.begin(), key_iter.end(), expected_vals);
30 }
31
32 TEST(MapIteratorTest, ValueIterator) {
33 Map<int, int> my_map;
34 my_map[1] = 2;
35 my_map[3] = 4;
36 my_map[5] = 6;
37
38 MapValueIterator<int, int> value_iter(&my_map);
39 std::vector<int> expected_vals;
40 expected_vals.push_back(2);
41 expected_vals.push_back(4);
42 expected_vals.push_back(6);
43 ExpectIteratorValues(value_iter.begin(), value_iter.end(), expected_vals);
44 }
45
46 TEST(MapIteratorTest, BidirectionalIteratorConcept) {
47 Map<int, int> my_map;
48 my_map[1] = 2;
49 my_map[3] = 4;
50 my_map[5] = 6;
51
52 // Test common IteratorView specializations for Map keys, Map values, and
53 // Arrays.
54 MapKeyIterator<int, int> map_key_iter(&my_map);
55 MapValueIterator<int, int> map_value_iter(&my_map);
56
57 {
58 SCOPED_TRACE("Test map key iterator bidirectionality.");
59 std::vector<int> expected_vals;
60 expected_vals.push_back(1);
61 expected_vals.push_back(3);
62 expected_vals.push_back(5);
63 ExpectBidiIteratorConcept(map_key_iter.begin(), map_key_iter.end(),
64 expected_vals);
65 }
66
67 {
68 SCOPED_TRACE("Test map value iterator bidirectionality.");
69 std::vector<int> expected_vals;
70 expected_vals.push_back(2);
71 expected_vals.push_back(4);
72 expected_vals.push_back(6);
73 ExpectBidiIteratorConcept(map_value_iter.begin(), map_value_iter.end(),
74 expected_vals);
75 }
76
77 {
78 SCOPED_TRACE("Test map value iterator mutability.");
79 std::vector<int> expected_vals;
80 expected_vals.push_back(2);
81 expected_vals.push_back(4);
82 expected_vals.push_back(6);
83 ExpectBidiMutableIteratorConcept(map_value_iter.begin(),
84 map_value_iter.end(), expected_vals);
85 }
86 }
87
88 } // namespace test
89 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/iterator_test_util.h ('k') | mojo/public/cpp/bindings/tests/map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698