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 : const char MockNamedBlockGraphTransform::kTransformName[] =
53 : "MockNamedBlockGraphTransform";
54 :
55 : const char MockNamedBasicBlockSubGraphTransform::kTransformName[] =
56 : "MockNamedBasicBlockSubGraphTransform";
57 :
58 : } // namespace
59 :
60 E : TEST(NamedBlockGraphTransformTest, NameWorks) {
61 E : MockNamedBlockGraphTransform transform;
62 E : EXPECT_EQ(std::string("MockNamedBlockGraphTransform"), transform.name());
63 E : }
64 :
65 E : TEST(NamedBasicBlockSubGraphTransformTest, NameWorks) {
66 E : MockNamedBasicBlockSubGraphTransform transform;
67 : EXPECT_EQ(std::string("MockNamedBasicBlockSubGraphTransform"),
68 E : transform.name());
69 E : }
70 :
71 : } // namespace transforms
72 : } // namespace block_graph
|