1 : // Copyright 2012 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 : // Unittests for transform name implementation class.
16 :
17 : #include "syzygy/block_graph/transforms/named_transform.h"
18 :
19 : #include "gtest/gtest.h"
20 :
21 : namespace block_graph {
22 : namespace transforms {
23 :
24 : namespace {
25 :
26 : class MockNamedBlockGraphTransform :
27 : public NamedBlockGraphTransformImpl<MockNamedBlockGraphTransform> {
28 : public:
29 : bool TransformBlockGraph(const TransformPolicyInterface* /*policy*/,
30 : BlockGraph* /*block_graph*/,
31 i : BlockGraph::Block* /*header_block*/) {
32 i : return true;
33 i : }
34 :
35 : static const char kTransformName[];
36 : };
37 :
38 : class MockNamedBasicBlockSubGraphTransform :
39 : public NamedBasicBlockSubGraphTransformImpl<
40 : MockNamedBasicBlockSubGraphTransform> {
41 : public:
42 : bool TransformBasicBlockSubGraph(
43 : const TransformPolicyInterface* /*policy*/,
44 : BlockGraph* /*block_graph*/,
45 i : BasicBlockSubGraph* /*basic_block_subgraph*/) {
46 i : return true;
47 i : }
48 :
49 : static const char kTransformName[];
50 : };
51 :
52 : class MockNamedImageLayoutTransform :
53 : public NamedImageLayoutTransformImpl<MockNamedImageLayoutTransform> {
54 : public:
55 : bool TransformImageLayout(const TransformPolicyInterface* /*policy*/,
56 : const pe::ImageLayout* /*image_layout*/,
57 i : const OrderedBlockGraph* /*ordered_block_graph*/) {
58 i : return true;
59 i : }
60 :
61 : static const char kTransformName[];
62 : };
63 :
64 : const char MockNamedBlockGraphTransform::kTransformName[] =
65 : "MockNamedBlockGraphTransform";
66 :
67 : const char MockNamedBasicBlockSubGraphTransform::kTransformName[] =
68 : "MockNamedBasicBlockSubGraphTransform";
69 :
70 : const char MockNamedImageLayoutTransform::kTransformName[] =
71 : "MockNamedImageLayoutTransform";
72 :
73 : } // namespace
74 :
75 E : TEST(NamedBlockGraphTransformTest, NameWorks) {
76 E : MockNamedBlockGraphTransform transform;
77 E : EXPECT_EQ(std::string("MockNamedBlockGraphTransform"), transform.name());
78 E : }
79 :
80 E : TEST(NamedBasicBlockSubGraphTransformTest, NameWorks) {
81 E : MockNamedBasicBlockSubGraphTransform transform;
82 E : EXPECT_EQ(std::string("MockNamedBasicBlockSubGraphTransform"),
83 E : transform.name());
84 E : }
85 :
86 E : TEST(NamedImageLayoutTransformTest, NameWorks) {
87 E : MockNamedImageLayoutTransform transform;
88 E : EXPECT_EQ(std::string("MockNamedImageLayoutTransform"), transform.name());
89 E : }
90 :
91 : } // namespace transforms
92 : } // namespace block_graph
|