| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "wtf/text/StringView.h" | 5 #include "wtf/text/StringView.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "wtf/text/AtomicString.h" | 8 #include "wtf/text/AtomicString.h" |
| 9 #include "wtf/text/StringImpl.h" | 9 #include "wtf/text/StringImpl.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 EXPECT_FALSE(StringView(String(kChars)).isEmpty()); | 359 EXPECT_FALSE(StringView(String(kChars)).isEmpty()); |
| 360 EXPECT_TRUE(StringView(String(kChars), 5).isEmpty()); | 360 EXPECT_TRUE(StringView(String(kChars), 5).isEmpty()); |
| 361 EXPECT_TRUE(StringView(String(kChars), 4, 0).isEmpty()); | 361 EXPECT_TRUE(StringView(String(kChars), 4, 0).isEmpty()); |
| 362 EXPECT_TRUE(StringView().isEmpty()); | 362 EXPECT_TRUE(StringView().isEmpty()); |
| 363 EXPECT_TRUE(StringView("").isEmpty()); | 363 EXPECT_TRUE(StringView("").isEmpty()); |
| 364 EXPECT_TRUE(StringView(reinterpret_cast<const UChar*>(u"")).isEmpty()); | 364 EXPECT_TRUE(StringView(reinterpret_cast<const UChar*>(u"")).isEmpty()); |
| 365 EXPECT_FALSE(StringView(kChars16).isEmpty()); | 365 EXPECT_FALSE(StringView(kChars16).isEmpty()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 TEST(StringViewTest, ToString) { | 368 TEST(StringViewTest, ToString) { |
| 369 EXPECT_EQ(emptyString().impl(), StringView("").toString().impl()); | 369 EXPECT_EQ(emptyString.impl(), StringView("").toString().impl()); |
| 370 EXPECT_EQ(nullAtom.impl(), StringView().toString().impl()); | 370 EXPECT_EQ(nullAtom.impl(), StringView().toString().impl()); |
| 371 // NOTE: All the construction tests also check toString(). | 371 // NOTE: All the construction tests also check toString(). |
| 372 } | 372 } |
| 373 | 373 |
| 374 TEST(StringViewTest, ToAtomicString) { | 374 TEST(StringViewTest, ToAtomicString) { |
| 375 EXPECT_EQ(nullAtom.impl(), StringView().toAtomicString()); | 375 EXPECT_EQ(nullAtom.impl(), StringView().toAtomicString()); |
| 376 EXPECT_EQ(emptyAtom.impl(), StringView("").toAtomicString()); | 376 EXPECT_EQ(emptyAtom.impl(), StringView("").toAtomicString()); |
| 377 EXPECT_EQ(AtomicString("12"), StringView(kChars8, 2).toAtomicString()); | 377 EXPECT_EQ(AtomicString("12"), StringView(kChars8, 2).toAtomicString()); |
| 378 // AtomicString will convert to 8bit if possible when creating the string. | 378 // AtomicString will convert to 8bit if possible when creating the string. |
| 379 EXPECT_EQ(AtomicString("12").impl(), | 379 EXPECT_EQ(AtomicString("12").impl(), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "INKL")); | 449 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "INKL")); |
| 450 EXPECT_FALSE( | 450 EXPECT_FALSE( |
| 451 equalIgnoringASCIICase(StringView("link"), "link different length")); | 451 equalIgnoringASCIICase(StringView("link"), "link different length")); |
| 452 EXPECT_FALSE( | 452 EXPECT_FALSE( |
| 453 equalIgnoringASCIICase(StringView("link different length"), "link")); | 453 equalIgnoringASCIICase(StringView("link different length"), "link")); |
| 454 | 454 |
| 455 EXPECT_TRUE(equalIgnoringASCIICase(StringView(""), "")); | 455 EXPECT_TRUE(equalIgnoringASCIICase(StringView(""), "")); |
| 456 } | 456 } |
| 457 | 457 |
| 458 } // namespace WTF | 458 } // namespace WTF |
| OLD | NEW |