| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 EXPECT_STREQ(referenceString, string.data()); | 80 EXPECT_STREQ(referenceString, string.data()); |
| 81 | 81 |
| 82 CString stringWithLength(referenceString, 6); | 82 CString stringWithLength(referenceString, 6); |
| 83 EXPECT_FALSE(stringWithLength.isNull()); | 83 EXPECT_FALSE(stringWithLength.isNull()); |
| 84 EXPECT_EQ(strlen(referenceString), stringWithLength.length()); | 84 EXPECT_EQ(strlen(referenceString), stringWithLength.length()); |
| 85 EXPECT_STREQ(referenceString, stringWithLength.data()); | 85 EXPECT_STREQ(referenceString, stringWithLength.data()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST(CStringTest, UninitializedConstructor) { | 88 TEST(CStringTest, UninitializedConstructor) { |
| 89 char* buffer; | 89 char* buffer; |
| 90 CString emptyString = CString::newUninitialized(0, buffer); | 90 CString emptyString = CString::createUninitialized(0, buffer); |
| 91 EXPECT_FALSE(emptyString.isNull()); | 91 EXPECT_FALSE(emptyString.isNull()); |
| 92 EXPECT_EQ(buffer, emptyString.data()); | 92 EXPECT_EQ(buffer, emptyString.data()); |
| 93 EXPECT_EQ(0, buffer[0]); | 93 EXPECT_EQ(0, buffer[0]); |
| 94 | 94 |
| 95 const size_t length = 25; | 95 const size_t length = 25; |
| 96 CString uninitializedString = CString::newUninitialized(length, buffer); | 96 CString uninitializedString = CString::createUninitialized(length, buffer); |
| 97 EXPECT_FALSE(uninitializedString.isNull()); | 97 EXPECT_FALSE(uninitializedString.isNull()); |
| 98 EXPECT_EQ(buffer, uninitializedString.data()); | 98 EXPECT_EQ(buffer, uninitializedString.data()); |
| 99 EXPECT_EQ(0, uninitializedString.data()[length]); | 99 EXPECT_EQ(0, uninitializedString.data()[length]); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST(CStringTest, ZeroTerminated) { | 102 TEST(CStringTest, ZeroTerminated) { |
| 103 const char* referenceString = "WebKit"; | 103 const char* referenceString = "WebKit"; |
| 104 CString stringWithLength(referenceString, 3); | 104 CString stringWithLength(referenceString, 3); |
| 105 EXPECT_EQ(0, stringWithLength.data()[3]); | 105 EXPECT_EQ(0, stringWithLength.data()[3]); |
| 106 } | 106 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 TEST(CStringTest, Printer) { | 194 TEST(CStringTest, Printer) { |
| 195 EXPECT_STREQ("<null>", printedString(CString()).data()); | 195 EXPECT_STREQ("<null>", printedString(CString()).data()); |
| 196 EXPECT_STREQ("\"abc\"", printedString("abc").data()); | 196 EXPECT_STREQ("\"abc\"", printedString("abc").data()); |
| 197 EXPECT_STREQ("\"\\t\\n\\r\\\"\\\\\"", printedString("\t\n\r\"\\").data()); | 197 EXPECT_STREQ("\"\\t\\n\\r\\\"\\\\\"", printedString("\t\n\r\"\\").data()); |
| 198 EXPECT_STREQ("\"\\xFF\\x00\\x01xyz\"", | 198 EXPECT_STREQ("\"\\xFF\\x00\\x01xyz\"", |
| 199 printedString(CString("\xff\0\x01xyz", 6)).data()); | 199 printedString(CString("\xff\0\x01xyz", 6)).data()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace WTF | 202 } // namespace WTF |
| OLD | NEW |