Index: remoting/base/capabilities_unittest.cc |
diff --git a/remoting/base/capabilities_unittest.cc b/remoting/base/capabilities_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6ae3fc823b3be4df11856848c7015cec7eb259fc |
--- /dev/null |
+++ b/remoting/base/capabilities_unittest.cc |
@@ -0,0 +1,48 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "remoting/base/capabilities.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace remoting { |
+ |
+TEST(CapabilitiesTest, Empty) { |
+ // Expect that nothing can be found in an empty set. |
+ EXPECT_FALSE(HasCapability("", "a")); |
+ EXPECT_FALSE(HasCapability(" ", "a")); |
+ EXPECT_FALSE(HasCapability(" ", "a")); |
+ |
+ // Expect that nothing can be found in an empty set, event when the key is |
+ // empty. |
+ EXPECT_FALSE(HasCapability("", "")); |
+ EXPECT_FALSE(HasCapability(" ", "")); |
+ EXPECT_FALSE(HasCapability(" ", "")); |
+ |
+ // Intersection with an empty set given an empty set. |
+ EXPECT_EQ(IntersectCapabilities("", ""), ""); |
+ EXPECT_EQ(IntersectCapabilities(" ", ""), ""); |
+ EXPECT_EQ(IntersectCapabilities("a", ""), ""); |
+ EXPECT_EQ(IntersectCapabilities("", " "), ""); |
+ EXPECT_EQ(IntersectCapabilities(" ", " "), ""); |
+ EXPECT_EQ(IntersectCapabilities("a", " "), ""); |
+ EXPECT_EQ(IntersectCapabilities("", "a"), ""); |
+ EXPECT_EQ(IntersectCapabilities(" ", "a"), ""); |
+} |
+ |
+TEST(CapabilitiesTest, HasCapability) { |
+ EXPECT_TRUE(HasCapability("a", "a")); |
+ EXPECT_TRUE(HasCapability("a a", "a")); |
+ EXPECT_TRUE(HasCapability("a b", "a")); |
+ EXPECT_FALSE(HasCapability("a", "b")); |
+ EXPECT_FALSE(HasCapability("a a", "b")); |
+ EXPECT_TRUE(HasCapability("a b", "b")); |
+} |
+ |
+TEST(CapabilitiesTest, Intersect) { |
+ EXPECT_EQ(IntersectCapabilities("a", "a"), "a"); |
+ EXPECT_EQ(IntersectCapabilities("a b", "a"), "a"); |
+ 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.
|
+} |
+ |
+} // namespace remoting |