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

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

Issue 2473093003: Fix up naming in CString. (Closed)
Patch Set: Created 4 years, 1 month 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 /* 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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CString.cpp ('k') | third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698