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

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: rebase 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, DefaultIsNull) {
12 String s;
13 EXPECT_TRUE(s.is_null());
14 }
15
16 TEST(StringTest, ConstructedWithNULL) {
17 String s(NULL);
18 EXPECT_TRUE(s.is_null());
19 }
20
21 TEST(StringTest, ConstructedWithNullCharPointer) {
22 const char* null = NULL;
23 String s(null);
24 EXPECT_TRUE(s.is_null());
25 }
26
27 TEST(StringTest, AssignedNULL) {
28 String s("");
29 EXPECT_FALSE(s.is_null());
30 s = NULL;
31 EXPECT_TRUE(s.is_null());
32 }
33
34 TEST(StringTest, Empty) {
35 String s("");
36 EXPECT_FALSE(s.is_null());
37 EXPECT_TRUE(s.get().empty());
38 }
39
40 TEST(StringTest, Basic) {
41 String s("hello world");
42 EXPECT_EQ(std::string("hello world"), s.get());
43 }
44
45 TEST(StringTest, Assignment) {
46 String s("hello world");
47 String t = s; // Makes a copy.
48 EXPECT_FALSE(t.is_null());
49 EXPECT_EQ(std::string("hello world"), t.get());
50 EXPECT_FALSE(s.is_null());
51 }
52
53 TEST(StringTest, Equality) {
54 String s("hello world");
55 String t("hello world");
56 EXPECT_EQ(s, t);
57 EXPECT_TRUE(s == t);
58 EXPECT_TRUE("hello world" == s);
59 EXPECT_TRUE(s == "hello world");
60 EXPECT_TRUE("not" != s);
61 EXPECT_TRUE(s != "not");
62 }
63
64 } // namespace test
65 } // namespace mojo
OLDNEW
« 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