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

Unified Diff: mojo/public/cpp/bindings/tests/string_unittest.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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..9844ee9fca1d09ac2757788b03eb82036c6e0e0f
--- /dev/null
+++ b/mojo/public/cpp/bindings/tests/string_unittest.cc
@@ -0,0 +1,65 @@
+// 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 {
+
+TEST(StringTest, DefaultIsNull) {
+ String s;
+ EXPECT_TRUE(s.is_null());
+}
+
+TEST(StringTest, ConstructedWithNULL) {
+ String s(NULL);
+ EXPECT_TRUE(s.is_null());
+}
+
+TEST(StringTest, ConstructedWithNullCharPointer) {
+ const char* null = NULL;
+ String s(null);
+ EXPECT_TRUE(s.is_null());
+}
+
+TEST(StringTest, AssignedNULL) {
+ String s("");
+ EXPECT_FALSE(s.is_null());
+ s = NULL;
+ EXPECT_TRUE(s.is_null());
+}
+
+TEST(StringTest, Empty) {
+ String s("");
+ EXPECT_FALSE(s.is_null());
+ EXPECT_TRUE(s.get().empty());
+}
+
+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
« no previous file with comments | « mojo/public/cpp/bindings/tests/sample_service_unittest.cc ('k') | mojo/public/cpp/bindings/tests/struct_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698