1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/bard/trace_live_map.h"
16 :
17 : #include "gtest/gtest.h"
18 : #include "syzygy/bard/unittest_util.h"
19 :
20 : namespace bard {
21 :
22 E : TEST(TraceLiveMapTest, TestMapping) {
23 E : TraceLiveMap<void*> trace_live_map;
24 :
25 E : void* trace = reinterpret_cast<void*>(0xAB11CD22);
26 E : void* extra_trace = reinterpret_cast<void*>(0x13213221);
27 E : void* live = reinterpret_cast<void*>(0xCC9437A2);
28 E : void* extra_live = reinterpret_cast<void*>(0xABBAABBA);
29 :
30 E : EXPECT_TRUE(trace_live_map.AddMapping(trace, live));
31 E : EXPECT_FALSE(trace_live_map.AddMapping(trace, extra_live));
32 E : EXPECT_FALSE(trace_live_map.AddMapping(extra_trace, live));
33 E : testing::CheckTraceLiveMapContains(trace_live_map, trace, live);
34 :
35 E : EXPECT_TRUE(trace_live_map.RemoveMapping(trace, live));
36 E : testing::CheckTraceLiveMapNotContain(trace_live_map, trace, live);
37 :
38 E : EXPECT_FALSE(trace_live_map.RemoveMapping(trace, live));
39 E : }
40 :
41 : } // namespace bard
|