OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/public/cpp/bindings/string.h" | 5 #include "mojo/public/cpp/bindings/string.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace mojo { | 8 namespace mojo { |
9 namespace test { | 9 namespace test { |
10 | 10 |
11 TEST(StringTest, DefaultIsNull) { | 11 TEST(StringTest, DefaultIsNull) { |
12 String s; | 12 String s; |
13 EXPECT_TRUE(s.is_null()); | 13 EXPECT_TRUE(s.is_null()); |
14 } | 14 } |
15 | 15 |
16 TEST(StringTest, ConstructedWithNULL) { | 16 TEST(StringTest, ConstructedWithNULL) { |
17 String s(NULL); | 17 String s(nullptr); |
18 EXPECT_TRUE(s.is_null()); | 18 EXPECT_TRUE(s.is_null()); |
19 } | 19 } |
20 | 20 |
21 TEST(StringTest, ConstructedWithNullCharPointer) { | 21 TEST(StringTest, ConstructedWithNullCharPointer) { |
22 const char* null = NULL; | 22 const char* null = nullptr; |
23 String s(null); | 23 String s(null); |
24 EXPECT_TRUE(s.is_null()); | 24 EXPECT_TRUE(s.is_null()); |
25 } | 25 } |
26 | 26 |
27 TEST(StringTest, AssignedNULL) { | 27 TEST(StringTest, AssignedNULL) { |
28 String s(""); | 28 String s(""); |
29 EXPECT_FALSE(s.is_null()); | 29 EXPECT_FALSE(s.is_null()); |
30 s = NULL; | 30 s = nullptr; |
31 EXPECT_TRUE(s.is_null()); | 31 EXPECT_TRUE(s.is_null()); |
32 } | 32 } |
33 | 33 |
34 TEST(StringTest, Empty) { | 34 TEST(StringTest, Empty) { |
35 String s(""); | 35 String s(""); |
36 EXPECT_FALSE(s.is_null()); | 36 EXPECT_FALSE(s.is_null()); |
37 EXPECT_TRUE(s.get().empty()); | 37 EXPECT_TRUE(s.get().empty()); |
38 } | 38 } |
39 | 39 |
40 TEST(StringTest, Basic) { | 40 TEST(StringTest, Basic) { |
(...skipping 15 matching lines...) Expand all Loading... |
56 EXPECT_EQ(s, t); | 56 EXPECT_EQ(s, t); |
57 EXPECT_TRUE(s == t); | 57 EXPECT_TRUE(s == t); |
58 EXPECT_TRUE("hello world" == s); | 58 EXPECT_TRUE("hello world" == s); |
59 EXPECT_TRUE(s == "hello world"); | 59 EXPECT_TRUE(s == "hello world"); |
60 EXPECT_TRUE("not" != s); | 60 EXPECT_TRUE("not" != s); |
61 EXPECT_TRUE(s != "not"); | 61 EXPECT_TRUE(s != "not"); |
62 } | 62 } |
63 | 63 |
64 } // namespace test | 64 } // namespace test |
65 } // namespace mojo | 65 } // namespace mojo |
OLD | NEW |