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

Side by Side Diff: base/memory/ref_counted_memory_unittest.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/memory/ref_counted_memory.cc ('k') | chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/memory/ref_counted_memory.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace base {
10
11 TEST(RefCountedMemoryUnitTest, RefCountedStaticMemory) {
12 scoped_refptr<RefCountedMemory> mem = new RefCountedStaticMemory(
13 reinterpret_cast<const uint8*>("static mem00"), 10);
14
15 EXPECT_EQ(10U, mem->size());
16 EXPECT_EQ("static mem",
17 std::string(reinterpret_cast<const char*>(mem->front()),
18 mem->size()));
19 }
20
21 TEST(RefCountedMemoryUnitTest, RefCountedBytes) {
22 std::vector<uint8> data;
23 data.push_back(45);
24 data.push_back(99);
25 scoped_refptr<RefCountedMemory> mem = RefCountedBytes::TakeVector(&data);
26
27 EXPECT_EQ(0U, data.size());
28
29 EXPECT_EQ(2U, mem->size());
30 EXPECT_EQ(45U, mem->front()[0]);
31 EXPECT_EQ(99U, mem->front()[1]);
32 }
33
34 TEST(RefCountedMemoryUnitTest, RefCountedString) {
35 std::string s("destroy me");
36 scoped_refptr<RefCountedMemory> mem = RefCountedString::TakeString(&s);
37
38 EXPECT_EQ(0U, s.size());
39
40 EXPECT_EQ(10U, mem->size());
41 EXPECT_EQ('d', mem->front()[0]);
42 EXPECT_EQ('e', mem->front()[1]);
43 }
44
45 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/ref_counted_memory.cc ('k') | chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698