Index: mojo/public/cpp/bindings/tests/string_unittest.cc |
diff --git a/mojo/public/cpp/bindings/tests/string_unittest.cc b/mojo/public/cpp/bindings/tests/string_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b875ce8e7f645e54a6a902a2c557767822673e63 |
--- /dev/null |
+++ b/mojo/public/cpp/bindings/tests/string_unittest.cc |
@@ -0,0 +1,44 @@ |
+// Copyright 2014 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 "mojo/public/cpp/bindings/string.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace mojo { |
+namespace test { |
+namespace { |
yzshen1
2014/05/27 22:16:59
nit: please remove this empty namespace.
|
+ |
+} // namespace |
+ |
+TEST(StringTest, Null) { |
+ String s; |
+ EXPECT_TRUE(s.is_null()); |
+} |
+ |
+TEST(StringTest, Basic) { |
+ String s("hello world"); |
+ EXPECT_EQ(std::string("hello world"), s.get()); |
+} |
+ |
+TEST(StringTest, Assignment) { |
+ String s("hello world"); |
+ String t = s; // Makes a copy. |
+ EXPECT_FALSE(t.is_null()); |
+ EXPECT_EQ(std::string("hello world"), t.get()); |
+ EXPECT_FALSE(s.is_null()); |
+} |
+ |
+TEST(StringTest, Equality) { |
+ String s("hello world"); |
+ String t("hello world"); |
+ EXPECT_EQ(s, t); |
+ EXPECT_TRUE(s == t); |
+ EXPECT_TRUE("hello world" == s); |
+ EXPECT_TRUE(s == "hello world"); |
+ EXPECT_TRUE("not" != s); |
+ EXPECT_TRUE(s != "not"); |
+} |
+ |
+} // namespace test |
+} // namespace mojo |