diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-07 11:22:47 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-07 11:22:47 +0100 |
commit | cfd86b747d32ac22246a1aa908eaa720c63a88c1 (patch) | |
tree | 24d68c6f61c464ecba1e05670b80390ea3b0e50c /Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp | |
parent | 69d7c744c9de19d152dbe2d8e46eb7dfd4511d1a (diff) | |
download | qtwebkit-cfd86b747d32ac22246a1aa908eaa720c63a88c1.tar.gz |
Imported WebKit commit 20271caf2e2c016d5cef40184cddeefeac4f1876 (http://svn.webkit.org/repository/webkit/trunk@133733)
New snapshot that contains all previous fixes as well as build fix for latest QtMultimedia API changes.
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp')
-rw-r--r-- | Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp b/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp index 213a655aa..35d64844c 100644 --- a/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp +++ b/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp @@ -26,6 +26,7 @@ #include "config.h" #include <wtf/text/StringImpl.h> +#include <wtf/text/WTFString.h> namespace TestWebKitAPI { @@ -68,4 +69,48 @@ TEST(WTF, StringImplFromLiteralLoop16BitConversion) } } +TEST(WTF, StringImplReplaceWithLiteral) +{ + RefPtr<StringImpl> testStringImpl = StringImpl::createFromLiteral("1224"); + ASSERT_TRUE(testStringImpl->is8Bit()); + + // Cases for 8Bit source. + testStringImpl = testStringImpl->replace('2', "", 0); + ASSERT_TRUE(equal(testStringImpl.get(), "14")); + + testStringImpl = StringImpl::createFromLiteral("1224"); + ASSERT_TRUE(testStringImpl->is8Bit()); + + testStringImpl = testStringImpl->replace('3', "NotFound", 8); + ASSERT_TRUE(equal(testStringImpl.get(), "1224")); + + testStringImpl = testStringImpl->replace('2', "3", 1); + ASSERT_TRUE(equal(testStringImpl.get(), "1334")); + + testStringImpl = StringImpl::createFromLiteral("1224"); + ASSERT_TRUE(testStringImpl->is8Bit()); + testStringImpl = testStringImpl->replace('2', "555", 3); + ASSERT_TRUE(equal(testStringImpl.get(), "15555554")); + + // Cases for 16Bit source. + String testString = String::fromUTF8("résumé"); + ASSERT_FALSE(testString.impl()->is8Bit()); + + testStringImpl = testString.impl()->replace('2', "NotFound", 8); + ASSERT_TRUE(equal(testStringImpl.get(), String::fromUTF8("résumé").impl())); + + testStringImpl = testString.impl()->replace(UChar(0x00E9 /*U+00E9 is 'é'*/), "e", 1); + ASSERT_TRUE(equal(testStringImpl.get(), "resume")); + + testString = String::fromUTF8("résumé"); + ASSERT_FALSE(testString.impl()->is8Bit()); + testStringImpl = testString.impl()->replace(UChar(0x00E9 /*U+00E9 is 'é'*/), "", 0); + ASSERT_TRUE(equal(testStringImpl.get(), "rsum")); + + testString = String::fromUTF8("résumé"); + ASSERT_FALSE(testString.impl()->is8Bit()); + testStringImpl = testString.impl()->replace(UChar(0x00E9 /*U+00E9 is 'é'*/), "555", 3); + ASSERT_TRUE(equal(testStringImpl.get(), "r555sum555")); +} + } // namespace TestWebKitAPI |