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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringViewTest.cpp

Issue 2140353002: Move StringView constructors into WTFString.h/AtomicString.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused constructor. Created 4 years, 5 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
OLDNEW
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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // StringView(const UChar* chars, unsigned length); 282 // StringView(const UChar* chars, unsigned length);
283 ASSERT_FALSE(StringView(kChars16, 2).is8Bit()); 283 ASSERT_FALSE(StringView(kChars16, 2).is8Bit());
284 EXPECT_FALSE(StringView(kChars16, 2).isNull()); 284 EXPECT_FALSE(StringView(kChars16, 2).isNull());
285 EXPECT_EQ(kChars16, StringView(kChars16, 2).characters16()); 285 EXPECT_EQ(kChars16, StringView(kChars16, 2).characters16());
286 EXPECT_EQ(StringView("12"), StringView(kChars16, 2)); 286 EXPECT_EQ(StringView("12"), StringView(kChars16, 2));
287 EXPECT_EQ(StringView(reinterpret_cast<const UChar*>(u"12")), StringView(kCha rs16, 2)); 287 EXPECT_EQ(StringView(reinterpret_cast<const UChar*>(u"12")), StringView(kCha rs16, 2));
288 EXPECT_EQ(2u, StringView(kChars16, 2).length()); 288 EXPECT_EQ(2u, StringView(kChars16, 2).length());
289 EXPECT_EQ(String("12"), StringView(kChars16, 2).toString()); 289 EXPECT_EQ(String("12"), StringView(kChars16, 2).toString());
290 } 290 }
291 291
292 TEST(StringViewTest, ConstructionRawBytes)
293 {
294 // StringView(const void* bytes, unsigned length, bool is8Bit);
295 StringView view8(reinterpret_cast<const void*>(kChars), 2, true);
296 ASSERT_TRUE(view8.is8Bit());
297 EXPECT_EQ(2u, view8.length());
298 EXPECT_EQ("12", view8);
299
300 StringView view16(reinterpret_cast<const void*>(kChars16), 3, false);
301 ASSERT_FALSE(view16.is8Bit());
302 EXPECT_EQ(3u, view16.length());
303 EXPECT_EQ("123", view16);
304 }
305
306 TEST(StringViewTest, IsEmpty) 292 TEST(StringViewTest, IsEmpty)
307 { 293 {
308 EXPECT_FALSE(StringView(kChars).isEmpty()); 294 EXPECT_FALSE(StringView(kChars).isEmpty());
309 EXPECT_TRUE(StringView(kChars, 0).isEmpty()); 295 EXPECT_TRUE(StringView(kChars, 0).isEmpty());
310 EXPECT_FALSE(StringView(String(kChars)).isEmpty()); 296 EXPECT_FALSE(StringView(String(kChars)).isEmpty());
311 EXPECT_TRUE(StringView(String(kChars), 5).isEmpty()); 297 EXPECT_TRUE(StringView(String(kChars), 5).isEmpty());
312 EXPECT_TRUE(StringView(String(kChars), 4, 0).isEmpty()); 298 EXPECT_TRUE(StringView(String(kChars), 4, 0).isEmpty());
313 EXPECT_TRUE(StringView().isEmpty()); 299 EXPECT_TRUE(StringView().isEmpty());
314 EXPECT_TRUE(StringView("").isEmpty()); 300 EXPECT_TRUE(StringView("").isEmpty());
315 EXPECT_TRUE(StringView(reinterpret_cast<const UChar*>(u"")).isEmpty()); 301 EXPECT_TRUE(StringView(reinterpret_cast<const UChar*>(u"")).isEmpty());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 387
402 EXPECT_TRUE(equalIgnoringASCIICase(StringView("link"), "lInK")); 388 EXPECT_TRUE(equalIgnoringASCIICase(StringView("link"), "lInK"));
403 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "INKL")); 389 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "INKL"));
404 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "link different leng th")); 390 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link"), "link different leng th"));
405 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link different length"), "li nk")); 391 EXPECT_FALSE(equalIgnoringASCIICase(StringView("link different length"), "li nk"));
406 392
407 EXPECT_TRUE(equalIgnoringASCIICase(StringView(""), "")); 393 EXPECT_TRUE(equalIgnoringASCIICase(StringView(""), ""));
408 } 394 }
409 395
410 } // namespace WTF 396 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringView.cpp ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698