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(BlockGraph* /*block_graph*/,
30 i : BlockGraph::Block* /*header_block*/) {
31 i : return true;
32 i : }
33 :
34 : static const char kTransformName[];
35 : };
36 :
37 : class MockNamedBasicBlockSubGraphTransform :
38 : public NamedBasicBlockSubGraphTransformImpl<
39 : MockNamedBasicBlockSubGraphTransform> {
40 : public:
41 : bool TransformBasicBlockSubGraph(
42 : BlockGraph* /*block_graph*/,
43 i : BasicBlockSubGraph* /*basic_block_subgraph*/) {
44 i : return true;
45 i : }
46 :
47 : static const char kTransformName[];
48 : };
49 :
50 : const char MockNamedBlockGraphTransform::kTransformName[] =
51 : "MockNamedBlockGraphTransform";
52 :
53 : const char MockNamedBasicBlockSubGraphTransform::kTransformName[] =
54 : "MockNamedBasicBlockSubGraphTransform";
55 :
56 : } // namespace
57 :
58 E : TEST(NamedBlockGraphTransformTest, NameWorks) {
59 E : MockNamedBlockGraphTransform transform;
60 E : EXPECT_EQ(std::string("MockNamedBlockGraphTransform"), transform.name());
61 E : }
62 :
63 E : TEST(NamedBasicBlockSubGraphTransformTest, NameWorks) {
64 E : MockNamedBasicBlockSubGraphTransform transform;
65 : EXPECT_EQ(std::string("MockNamedBasicBlockSubGraphTransform"),
66 E : transform.name());
67 E : }
68 :
69 : } // namespace transforms
70 : } // namespace block_graph
|