# Add unit tests
cvc4_add_cxx_unit_test_white(pass_bv_gauss_white preprocessing)
-cvc4_add_cxx_unit_test_white(pass_foreign_theory_rewrite_white preprocessing)
+cvc4_add_unit_test_white(pass_foreign_theory_rewrite_white preprocessing)
--- /dev/null
+/********************* */
+/*! \file pass_foreign_theory_rewrite_white.cpp
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Aina Niemetz, Yoni Zohar
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
+ ** in the top-level source directory and their institutional affiliations.
+ ** All rights reserved. See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief Unit tests for Foreign Theory Rerwrite prepricessing pass
+ ** Unit tests for Foreign Theory Rerwrite prepricessing pass
+ **/
+
+#include "expr/node_manager.h"
+#include "preprocessing/passes/foreign_theory_rewrite.h"
+#include "smt/smt_engine.h"
+#include "test_smt.h"
+
+namespace CVC4 {
+
+using namespace preprocessing::passes;
+
+namespace test {
+
+class TestPPWhiteForeignTheoryRewrite : public TestSmt
+{
+};
+
+TEST_F(TestPPWhiteForeignTheoryRewrite, simplify)
+{
+ std::cout << "len(x) >= 0 is simplified to true" << std::endl;
+ Node x = d_nodeManager->mkVar("x", d_nodeManager->stringType());
+ Node len_x = d_nodeManager->mkNode(kind::STRING_LENGTH, x);
+ Node zero = d_nodeManager->mkConst<Rational>(0);
+ Node geq1 = d_nodeManager->mkNode(kind::GEQ, len_x, zero);
+ Node tt = d_nodeManager->mkConst<bool>(true);
+ Node simplified1 = ForeignTheoryRewrite::foreignRewrite(geq1);
+ ASSERT_EQ(simplified1, tt);
+
+ std::cout << "len(x) >= n is not simplified to true" << std::endl;
+ Node n = d_nodeManager->mkVar("n", d_nodeManager->integerType());
+ Node geq2 = d_nodeManager->mkNode(kind::GEQ, len_x, n);
+ Node simplified2 = ForeignTheoryRewrite::foreignRewrite(geq2);
+ ASSERT_NE(simplified2, tt);
+}
+
+} // namespace test
+} // namespace CVC4
+++ /dev/null
-/********************* */
-/*! \file pass_foreign_theory_rewrite.h
- ** \verbatim
- ** Top contributors (to current version):
- ** Aina Niemetz, Mathias Preiner, Andres Noetzli
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
- ** in the top-level source directory and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief Unit tests for Foreign Theory Rerwrite prepricessing pass
- ** Unit tests for Foreign Theory Rerwrite prepricessing pass
- **/
-
-#include <cxxtest/TestSuite.h>
-
-#include "expr/node_manager.h"
-#include "preprocessing/passes/foreign_theory_rewrite.h"
-#include "smt/smt_engine.h"
-#include "test_utils.h"
-
-using namespace CVC4;
-using namespace CVC4::preprocessing::passes;
-
-class ForeignTheoryRewriteWhite : public CxxTest::TestSuite
-{
- public:
- ForeignTheoryRewriteWhite() {}
-
- void setUp() override
- {
- d_em = new ExprManager();
- d_nm = NodeManager::fromExprManager(d_em);
- d_smt = new SmtEngine(d_nm);
- d_smt->finishInit();
- }
-
- void tearDown() override
- {
- delete d_smt;
- delete d_em;
- }
-
- void testSimplify()
- {
- std::cout << "len(x) >= 0 is simplified to true" << std::endl;
- Node x = d_nm->mkVar("x", d_nm->stringType());
- Node len_x = d_nm->mkNode(kind::STRING_LENGTH, x);
- Node zero = d_nm->mkConst<Rational>(0);
- Node geq1 = d_nm->mkNode(kind::GEQ, len_x, zero);
- Node tt = d_nm->mkConst<bool>(true);
- Node simplified1 = ForeignTheoryRewrite::foreignRewrite(geq1);
- TS_ASSERT_EQUALS(simplified1, tt);
-
- std::cout << "len(x) >= n is not simplified to true" << std::endl;
- Node n = d_nm->mkVar("n", d_nm->integerType());
- Node geq2 = d_nm->mkNode(kind::GEQ, len_x, n);
- Node simplified2 = ForeignTheoryRewrite::foreignRewrite(geq2);
- TS_ASSERT(simplified2 != tt);
- }
-
- private:
- ExprManager* d_em;
- NodeManager* d_nm;
- SmtEngine* d_smt;
-};
--- /dev/null
+/********************* */
+/*! \file test_smt.h
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Aina Niemetz
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
+ ** in the top-level source directory and their institutional affiliations.
+ ** All rights reserved. See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief Common header for unit tests that need an SmtEngine.
+ **/
+
+#ifndef CVC4__TEST__UNIT__TEST_SMT_H
+#define CVC4__TEST__UNIT__TEST_SMT_H
+
+#include "expr/node_manager.h"
+#include "smt/smt_engine.h"
+#include "smt/smt_engine_scope.h"
+#include "test.h"
+
+namespace CVC4 {
+namespace test {
+
+class TestSmt : public TestInternal
+{
+ protected:
+ void SetUp() override
+ {
+ d_nodeManager.reset(new NodeManager(nullptr));
+ d_scope.reset(new NodeManagerScope(d_nodeManager.get()));
+ d_smtEngine.reset(new SmtEngine(d_nodeManager.get()));
+ d_smtEngine->finishInit();
+ }
+
+ std::unique_ptr<NodeManagerScope> d_scope;
+ std::unique_ptr<NodeManager> d_nodeManager;
+ std::unique_ptr<SmtEngine> d_smtEngine;
+};
+} // namespace test
+} // namespace CVC4
+#endif