blob: a29813b03efa6800c660b49392e5eaec4dfae72d [file] [log] [blame]
Clement Courbetac74acd2018-04-04 11:37:06 +00001//===-- OperandGraphTest.cpp ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "OperandGraph.h"
11#include "gmock/gmock.h"
12#include "gtest/gtest.h"
13
14using testing::ElementsAre;
15using testing::IsEmpty;
16using testing::Not;
17
18namespace exegesis {
19namespace graph {
20namespace {
21
22static const auto In = Node::In();
23static const auto Out = Node::Out();
24
25TEST(OperandGraphTest, NoPath) {
26 Graph TheGraph;
27 EXPECT_THAT(TheGraph.getPathFrom(In, Out), IsEmpty());
28}
29
30TEST(OperandGraphTest, Connecting) {
31 Graph TheGraph;
32 TheGraph.connect(In, Out);
33 EXPECT_THAT(TheGraph.getPathFrom(In, Out), Not(IsEmpty()));
34 EXPECT_THAT(TheGraph.getPathFrom(In, Out), ElementsAre(In, Out));
35}
36
37TEST(OperandGraphTest, ConnectingThroughVariable) {
38 const Node Var = Node::Var(1);
39 Graph TheGraph;
40 TheGraph.connect(In, Var);
41 TheGraph.connect(Var, Out);
42 EXPECT_THAT(TheGraph.getPathFrom(In, Out), Not(IsEmpty()));
43 EXPECT_THAT(TheGraph.getPathFrom(In, Out), ElementsAre(In, Var, Out));
44}
45
46} // namespace
47} // namespace graph
48} // namespace exegesis