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

Side by Side 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: improvements per review feedback Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "mojo/public/cpp/bindings/string.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace mojo {
9 namespace test {
10
11 TEST(StringTest, Null) {
12 String s;
13 EXPECT_TRUE(s.is_null());
14 }
15
16 TEST(StringTest, Null2) {
17 String s(NULL);
18 EXPECT_TRUE(s.is_null());
19 }
20
21 TEST(StringTest, Null3) {
22 const char* null = NULL;
23 String s(null);
24 EXPECT_TRUE(s.is_null());
25 }
26
27 TEST(StringTest, Empty) {
28 String s("");
29 EXPECT_FALSE(s.is_null());
30 EXPECT_TRUE(s.get().empty());
31 }
32
33 TEST(StringTest, Basic) {
34 String s("hello world");
35 EXPECT_EQ(std::string("hello world"), s.get());
36 }
37
38 TEST(StringTest, Assignment) {
39 String s("hello world");
40 String t = s; // Makes a copy.
41 EXPECT_FALSE(t.is_null());
42 EXPECT_EQ(std::string("hello world"), t.get());
43 EXPECT_FALSE(s.is_null());
44 }
45
46 TEST(StringTest, Equality) {
47 String s("hello world");
48 String t("hello world");
49 EXPECT_EQ(s, t);
50 EXPECT_TRUE(s == t);
51 EXPECT_TRUE("hello world" == s);
52 EXPECT_TRUE(s == "hello world");
53 EXPECT_TRUE("not" != s);
54 EXPECT_TRUE(s != "not");
55 }
56
57 } // namespace test
58 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698