OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "remoting/base/capabilities.h" | 10 #include "remoting/base/capabilities.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 }; | 60 }; |
61 | 61 |
62 // Verify that HasCapability(|capabilities|, |key|) returns |result|. | 62 // Verify that HasCapability(|capabilities|, |key|) returns |result|. |
63 // |result|. | 63 // |result|. |
64 for (size_t i = 0; i < arraysize(data); ++i) { | 64 for (size_t i = 0; i < arraysize(data); ++i) { |
65 std::vector<std::string> caps = base::SplitString( | 65 std::vector<std::string> caps = base::SplitString( |
66 data[i].capabilities, " ", base::KEEP_WHITESPACE, | 66 data[i].capabilities, " ", base::KEEP_WHITESPACE, |
67 base::SPLIT_WANT_NONEMPTY); | 67 base::SPLIT_WANT_NONEMPTY); |
68 do { | 68 do { |
69 EXPECT_EQ(data[i].result, | 69 EXPECT_EQ(data[i].result, |
70 HasCapability(JoinString(caps, " "), data[i].key)); | 70 HasCapability(base::JoinString(caps, " "), data[i].key)); |
71 } while (std::next_permutation(caps.begin(), caps.end())); | 71 } while (std::next_permutation(caps.begin(), caps.end())); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 TEST(CapabilitiesTest, Intersect) { | 75 TEST(CapabilitiesTest, Intersect) { |
76 EXPECT_EQ(IntersectCapabilities("a", "a"), "a"); | 76 EXPECT_EQ(IntersectCapabilities("a", "a"), "a"); |
77 | 77 |
78 IntersectTestData data[] = { | 78 IntersectTestData data[] = { |
79 { "", "", "" }, | 79 { "", "", "" }, |
80 { "a", "", "" }, | 80 { "a", "", "" }, |
(...skipping 10 matching lines...) Expand all Loading... |
91 { "a b c", "z", "" } | 91 { "a b c", "z", "" } |
92 }; | 92 }; |
93 | 93 |
94 // Verify that intersection of |right| with all permutations of |left| yields | 94 // Verify that intersection of |right| with all permutations of |left| yields |
95 // |result|. | 95 // |result|. |
96 for (size_t i = 0; i < arraysize(data); ++i) { | 96 for (size_t i = 0; i < arraysize(data); ++i) { |
97 std::vector<std::string> caps = base::SplitString( | 97 std::vector<std::string> caps = base::SplitString( |
98 data[i].left, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 98 data[i].left, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
99 do { | 99 do { |
100 EXPECT_EQ(data[i].result, | 100 EXPECT_EQ(data[i].result, |
101 IntersectCapabilities(JoinString(caps, " "), data[i].right)); | 101 IntersectCapabilities(base::JoinString(caps, " "), |
| 102 data[i].right)); |
102 } while (std::next_permutation(caps.begin(), caps.end())); | 103 } while (std::next_permutation(caps.begin(), caps.end())); |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 } // namespace remoting | 107 } // namespace remoting |
OLD | NEW |