blob: f6afc37dc285cfda35997025951d6da4afe60fca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/supports_user_data.h"
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
struct TestSupportsUserData : public SupportsUserData {};
struct UsesItself : public SupportsUserData::Data {
UsesItself(SupportsUserData* supports_user_data, const void* key)
: supports_user_data_(supports_user_data),
key_(key) {
}
virtual ~UsesItself() {
EXPECT_EQ(NULL, supports_user_data_->GetUserData(key_));
}
SupportsUserData* supports_user_data_;
const void* key_;
};
TEST(SupportsUserDataTest, ClearWorksRecursively) {
TestSupportsUserData supports_user_data;
char key = 0;
supports_user_data.SetUserData(&key,
new UsesItself(&supports_user_data, &key));
// Destruction of supports_user_data runs the actual test.
}
} // namespace
} // namespace base
|