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

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

Issue 126103003: Changed RefCountedStaticMemory() to accept a void pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 10 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
« no previous file with comments | « base/memory/ref_counted_memory.h ('k') | chrome/browser/android/dev_tools_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/ref_counted_memory.h" 5 #include "base/memory/ref_counted_memory.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 10
11 TEST(RefCountedMemoryUnitTest, RefCountedStaticMemory) { 11 TEST(RefCountedMemoryUnitTest, RefCountedStaticMemory) {
12 scoped_refptr<RefCountedMemory> mem = new RefCountedStaticMemory( 12 scoped_refptr<RefCountedMemory> mem = new RefCountedStaticMemory(
13 reinterpret_cast<const uint8*>("static mem00"), 10); 13 "static mem00", 10);
14 14
15 EXPECT_EQ(10U, mem->size()); 15 EXPECT_EQ(10U, mem->size());
16 EXPECT_EQ("static mem", 16 EXPECT_EQ("static mem", std::string(mem->front_as<char>(), mem->size()));
17 std::string(reinterpret_cast<const char*>(mem->front()),
18 mem->size()));
19 } 17 }
20 18
21 TEST(RefCountedMemoryUnitTest, RefCountedBytes) { 19 TEST(RefCountedMemoryUnitTest, RefCountedBytes) {
22 std::vector<uint8> data; 20 std::vector<uint8> data;
23 data.push_back(45); 21 data.push_back(45);
24 data.push_back(99); 22 data.push_back(99);
25 scoped_refptr<RefCountedMemory> mem = RefCountedBytes::TakeVector(&data); 23 scoped_refptr<RefCountedMemory> mem = RefCountedBytes::TakeVector(&data);
26 24
27 EXPECT_EQ(0U, data.size()); 25 EXPECT_EQ(0U, data.size());
28 26
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 EXPECT_FALSE(mem2->Equals(mem3)); 70 EXPECT_FALSE(mem2->Equals(mem3));
73 } 71 }
74 72
75 TEST(RefCountedMemoryUnitTest, EqualsNull) { 73 TEST(RefCountedMemoryUnitTest, EqualsNull) {
76 std::string s("str"); 74 std::string s("str");
77 scoped_refptr<RefCountedMemory> mem = RefCountedString::TakeString(&s); 75 scoped_refptr<RefCountedMemory> mem = RefCountedString::TakeString(&s);
78 EXPECT_FALSE(mem->Equals(NULL)); 76 EXPECT_FALSE(mem->Equals(NULL));
79 } 77 }
80 78
81 } // namespace base 79 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/ref_counted_memory.h ('k') | chrome/browser/android/dev_tools_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698