diff options
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp')
-rw-r--r-- | Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp index b0b133d..4202417 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp @@ -46,6 +46,27 @@ TEST(WebKit2, WKString) delete[] buffer; + maxSize = WKStringGetLength(string); + TEST_ASSERT(maxSize == 5); + + // Allocate a buffer one character larger than we need. + WKChar* uniBuffer = new WKChar[maxSize+1]; + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize); + TEST_ASSERT(actualSize == 5); + + WKChar helloBuffer[] = { 'h', 'e', 'l', 'l', 'o' }; + TEST_ASSERT(!memcmp(uniBuffer, helloBuffer, 10)); + + // Test passing a buffer length < the string length. + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize-1); + TEST_ASSERT(actualSize == 4); + + // Test passing a buffer length > the string length. + actualSize = WKStringGetCharacters(string, uniBuffer, maxSize+1); + TEST_ASSERT(actualSize == 5); + + delete[] uniBuffer; + WKRelease(string); } |