Changeset 191236 in webkit


Ignore:
Timestamp:
Oct 16, 2015, 9:48:50 PM (10 years ago)
Author:
akling@apple.com
Message:

[EFL, AppleWin] WTF.ConcatenateCharacterArrayAndEmptyString API test failed
<https://webkit.org/b/150153>

Unreviewed.

Just use simple arrays of LChar and UChar for this test instead of creating String
objects and then getting the characters8()/characters16() from them, since that
doesn't guarantee null-termination (the bug.)

  • TestWebKitAPI/Tests/WTF/StringOperators.cpp:

(TestWebKitAPI::TEST):
(TestWebKitAPI::build): Deleted.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r191214 r191236  
     12015-10-16  Andreas Kling  <akling@apple.com>
     2
     3        [EFL, AppleWin] WTF.ConcatenateCharacterArrayAndEmptyString API test failed
     4        <https://webkit.org/b/150153>
     5
     6        Unreviewed.
     7
     8        Just use simple arrays of LChar and UChar for this test instead of creating String
     9        objects and then getting the characters8()/characters16() from them, since that
     10        doesn't guarantee null-termination (the bug.)
     11
     12        * TestWebKitAPI/Tests/WTF/StringOperators.cpp:
     13        (TestWebKitAPI::TEST):
     14        (TestWebKitAPI::build): Deleted.
     15
    1162015-10-16  Tim Horton  <timothy_horton@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WTF/StringOperators.cpp

    r191069 r191236  
    3030static int wtfStringCopyCount;
    3131
    32 #include <wtf/text/StringBuilder.h>
    3332#include <wtf/text/WTFString.h>
    3433
    3534namespace TestWebKitAPI {
    36 
    37 static void build(StringBuilder& builder, std::vector<UChar> input)
    38 {
    39     builder.clear();
    40     for (auto codeUnit : input)
    41         builder.append(codeUnit);
    42 }
    4335
    4436#define EXPECT_N_WTF_STRING_COPIES(count, expr) \
     
    195187TEST(WTF, ConcatenateCharacterArrayAndEmptyString)
    196188{
    197     StringBuilder b;
    198 
    199     build(b, {0x9FF0, 0x868D, 'M', 'E'});
    200     String sixteenBitString = b.toString();
    201     EXPECT_FALSE(sixteenBitString.is8Bit());
    202     String concatenation = sixteenBitString.characters16() + String();
    203     ASSERT_EQ(sixteenBitString.length(), static_cast<unsigned>(4));
    204     ASSERT_EQ(concatenation.length(), static_cast<unsigned>(4));
    205     ASSERT_TRUE(concatenation == sixteenBitString);
    206 
    207     build(b, {'P', 'L', 'S'});
    208     String eightBitString = b.toString();
    209     EXPECT_TRUE(eightBitString.is8Bit());
    210     String concatenation8 = eightBitString.characters8() + String();
    211     ASSERT_EQ(eightBitString.length(), static_cast<unsigned>(3));
    212     ASSERT_EQ(concatenation8.length(), static_cast<unsigned>(3));
    213     ASSERT_TRUE(concatenation8 == eightBitString);
     189    String emptyString;
     190    EXPECT_EQ(static_cast<unsigned>(0), emptyString.length());
     191
     192    UChar ucharArray[] = { 't', 'e', 's', 't', '\0' };
     193    String concatenation16 = ucharArray + emptyString;
     194    ASSERT_EQ(static_cast<unsigned>(4), concatenation16.length());
     195    ASSERT_TRUE(concatenation16 == String(ucharArray));
     196
     197    LChar lcharArray[] = { 't', 'e', 's', 't', '\0' };
     198    String concatenation8 = lcharArray + emptyString;
     199    ASSERT_EQ(static_cast<unsigned>(4), concatenation8.length());
     200    ASSERT_TRUE(concatenation8 == String(lcharArray));
    214201}
    215202
Note: See TracChangeset for help on using the changeset viewer.