OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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/supports_user_data.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace base { | |
12 | |
13 namespace { | |
14 | |
15 struct TestSupportsUserData : public SupportsUserData {}; | |
16 | |
17 struct UsesItself : public SupportsUserData::Data { | |
18 UsesItself(SupportsUserData* supports_user_data, const void* key) | |
19 : supports_user_data_(supports_user_data), key_(key) {} | |
Peter Kasting
2014/05/28 03:44:13
Nit: One initializer per line if they don't all fi
Jeffrey Yasskin
2014/05/28 05:45:26
Done, and filed b/15292387.
| |
20 virtual ~UsesItself() { | |
21 EXPECT_EQ(NULL, supports_user_data_->GetUserData(key_)); | |
22 } | |
23 | |
24 SupportsUserData* supports_user_data_; | |
25 const void* key_; | |
26 }; | |
27 | |
28 TEST(SupportsUserDataTest, ClearWorksRecursively) { | |
29 TestSupportsUserData supports_user_data; | |
30 char key = 0; | |
31 supports_user_data.SetUserData(&key, | |
32 new UsesItself(&supports_user_data, &key)); | |
33 // Destruction of supports_user_data runs the actual test. | |
34 } | |
35 | |
36 } // namespace | |
37 } // namespace base | |
Peter Kasting
2014/05/28 03:44:13
Nit: Either add a blank line here or take it out a
Jeffrey Yasskin
2014/05/28 05:45:26
Thanks; I've taken it out above.
| |
OLD | NEW |