1695b41eeSopenharmony_ci// Copyright 2011 Google Inc. All Rights Reserved.
2695b41eeSopenharmony_ci//
3695b41eeSopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4695b41eeSopenharmony_ci// you may not use this file except in compliance with the License.
5695b41eeSopenharmony_ci// You may obtain a copy of the License at
6695b41eeSopenharmony_ci//
7695b41eeSopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8695b41eeSopenharmony_ci//
9695b41eeSopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10695b41eeSopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11695b41eeSopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12695b41eeSopenharmony_ci// See the License for the specific language governing permissions and
13695b41eeSopenharmony_ci// limitations under the License.
14695b41eeSopenharmony_ci
15695b41eeSopenharmony_ci#include "graph.h"
16695b41eeSopenharmony_ci#include "state.h"
17695b41eeSopenharmony_ci#include "test.h"
18695b41eeSopenharmony_ci
19695b41eeSopenharmony_ciusing namespace std;
20695b41eeSopenharmony_ci
21695b41eeSopenharmony_cinamespace {
22695b41eeSopenharmony_ci
23695b41eeSopenharmony_ciTEST(State, Basic) {
24695b41eeSopenharmony_ci  State state;
25695b41eeSopenharmony_ci
26695b41eeSopenharmony_ci  EvalString command;
27695b41eeSopenharmony_ci  command.AddText("cat ");
28695b41eeSopenharmony_ci  command.AddSpecial("in");
29695b41eeSopenharmony_ci  command.AddText(" > ");
30695b41eeSopenharmony_ci  command.AddSpecial("out");
31695b41eeSopenharmony_ci
32695b41eeSopenharmony_ci  Rule* rule = new Rule("cat");
33695b41eeSopenharmony_ci  rule->AddBinding("command", command);
34695b41eeSopenharmony_ci  state.bindings_.AddRule(rule);
35695b41eeSopenharmony_ci
36695b41eeSopenharmony_ci  Edge* edge = state.AddEdge(rule);
37695b41eeSopenharmony_ci  state.AddIn(edge, "in1", 0);
38695b41eeSopenharmony_ci  state.AddIn(edge, "in2", 0);
39695b41eeSopenharmony_ci  state.AddOut(edge, "out", 0);
40695b41eeSopenharmony_ci
41695b41eeSopenharmony_ci  EXPECT_EQ("cat in1 in2 > out", edge->EvaluateCommand());
42695b41eeSopenharmony_ci
43695b41eeSopenharmony_ci  EXPECT_FALSE(state.GetNode("in1", 0)->dirty());
44695b41eeSopenharmony_ci  EXPECT_FALSE(state.GetNode("in2", 0)->dirty());
45695b41eeSopenharmony_ci  EXPECT_FALSE(state.GetNode("out", 0)->dirty());
46695b41eeSopenharmony_ci}
47695b41eeSopenharmony_ci
48695b41eeSopenharmony_ci}  // namespace
49