Fawkes API  Fawkes Development Version
test_example.cpp
1 /***************************************************************************
2  * test_example.cpp - An exemplary CLIPS unit test
3  *
4  * Created: Mon 25 Sep 2017 16:47:31 CEST 16:47
5  * Copyright 2017 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #include "clips_test.h"
22 
23 /** Simple Test class that shows how to do unit testing for CLIPS. */
24 class SimpleCLIPSTest : public CLIPSTest
25 {
26 protected:
27  /** Set up the test environment. */
28  virtual void
30  {
31  LoadCLIPSFiles({"test_example.clp"});
32  }
33 };
34 
35 TEST_F(SimpleCLIPSTest, SimpleTest)
36 {
37  env.assert_fact("(testfact)");
38  env.assert_fact("(foo bar 4.2)");
39  CLIPS::Fact::pointer fact_p = env.get_facts();
40  env.run();
41  EXPECT_TRUE(has_fact("((?t testtempl))", "(eq ?t:name foo)"));
42  EXPECT_TRUE(has_fact("((?f foo))", "(eq ?f:implied (create$ bar 4.2))"));
43  EXPECT_FALSE(has_fact("((?t testtempl))", "(eq ?t:name bar)"));
44  EXPECT_FALSE(has_ordered_fact("foo"));
45  EXPECT_TRUE(has_ordered_fact("foo", {"bar", 4.2}));
46 }
Base class for unit testing with CLIPS.
Definition: clips_test.h:36
virtual void LoadCLIPSFiles(std::vector< std::string > files)
Load the vector of CLIPS files into the environment.
Definition: clips_test.h:43
Simple Test class that shows how to do unit testing for CLIPS.
virtual void SetUp()
Set up the test environment.