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

Unified Diff: third_party/WebKit/Source/platform/SharedBufferTest.cpp

Issue 2249533003: [Platform] Enable to get a partial data of SharedBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/SharedBuffer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/SharedBufferTest.cpp
diff --git a/third_party/WebKit/Source/platform/SharedBufferTest.cpp b/third_party/WebKit/Source/platform/SharedBufferTest.cpp
index a93154e52890ee1e4963f1e05745a1b296f5ff5f..904b274d7c626872a4754725ab04817a98e0b81b 100644
--- a/third_party/WebKit/Source/platform/SharedBufferTest.cpp
+++ b/third_party/WebKit/Source/platform/SharedBufferTest.cpp
@@ -59,6 +59,32 @@ TEST(SharedBufferTest, getAsBytes)
EXPECT_EQ(0, memcmp(expectedConcatenation, data.get(), strlen(expectedConcatenation)));
}
+TEST(SharedBufferTest, getPartAsBytes)
+{
+ char testData0[] = "Hello";
+ char testData1[] = "World";
+ char testData2[] = "Goodbye";
+
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(testData0, strlen(testData0));
+ sharedBuffer->append(testData1, strlen(testData1));
+ sharedBuffer->append(testData2, strlen(testData2));
+
+ struct TestData {
+ size_t position;
+ size_t size;
+ const char* expected;
+ } testData[] = {
+ {0, 17, "HelloWorldGoodbye"},
+ {0, 7, "HelloWo"},
+ {4, 7, "oWorldG"},
+ };
+ for (TestData& test : testData) {
+ std::unique_ptr<char[]> data = wrapArrayUnique(new char[test.size]);
+ ASSERT_TRUE(sharedBuffer->getPartAsBytes(data.get(), test.position, test.size));
+ EXPECT_EQ(0, memcmp(test.expected, data.get(), test.size));
+ }
+}
+
TEST(SharedBufferTest, getAsBytesLargeSegments)
{
Vector<char> vector0(0x4000);
« no previous file with comments | « third_party/WebKit/Source/platform/SharedBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698