OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/base/capabilities.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
8 namespace remoting { | |
9 | |
10 TEST(CapabilitiesTest, Empty) { | |
11 // Expect that nothing can be found in an empty set. | |
12 EXPECT_FALSE(HasCapability("", "a")); | |
13 EXPECT_FALSE(HasCapability(" ", "a")); | |
14 EXPECT_FALSE(HasCapability(" ", "a")); | |
15 | |
16 // Expect that nothing can be found in an empty set, event when the key is | |
17 // empty. | |
18 EXPECT_FALSE(HasCapability("", "")); | |
19 EXPECT_FALSE(HasCapability(" ", "")); | |
20 EXPECT_FALSE(HasCapability(" ", "")); | |
21 | |
22 // Intersection with an empty set given an empty set. | |
23 EXPECT_EQ(IntersectCapabilities("", ""), ""); | |
24 EXPECT_EQ(IntersectCapabilities(" ", ""), ""); | |
25 EXPECT_EQ(IntersectCapabilities("a", ""), ""); | |
26 EXPECT_EQ(IntersectCapabilities("", " "), ""); | |
27 EXPECT_EQ(IntersectCapabilities(" ", " "), ""); | |
28 EXPECT_EQ(IntersectCapabilities("a", " "), ""); | |
29 EXPECT_EQ(IntersectCapabilities("", "a"), ""); | |
30 EXPECT_EQ(IntersectCapabilities(" ", "a"), ""); | |
31 } | |
32 | |
33 TEST(CapabilitiesTest, HasCapability) { | |
34 EXPECT_TRUE(HasCapability("a", "a")); | |
35 EXPECT_TRUE(HasCapability("a a", "a")); | |
36 EXPECT_TRUE(HasCapability("a b", "a")); | |
37 EXPECT_FALSE(HasCapability("a", "b")); | |
38 EXPECT_FALSE(HasCapability("a a", "b")); | |
39 EXPECT_TRUE(HasCapability("a b", "b")); | |
40 } | |
41 | |
42 TEST(CapabilitiesTest, Intersect) { | |
43 EXPECT_EQ(IntersectCapabilities("a", "a"), "a"); | |
44 EXPECT_EQ(IntersectCapabilities("a b", "a"), "a"); | |
45 EXPECT_EQ(IntersectCapabilities("a b", "b"), "b"); | |
Sergey Ulanov
2013/04/18 00:34:53
Please add more complex tests, e.g. when the eleme
alexeypa (please no reviews)
2013/04/18 18:56:36
Done.
| |
46 } | |
47 | |
48 } // namespace remoting | |
OLD | NEW |