diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2021-11-15 09:35:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 09:35:27 -0600 |
commit | 829b3c2798c1f2c0bb313d7eff2c1e76f0184ae2 (patch) | |
tree | 6855fbf1b5bf7b11958a222f70e9301156931c0b /test/unit/api/cpp/solver_white.cpp | |
parent | 9aeb23f2ae58e4f6dd2b53dbb47cf8c173e56d83 (diff) | |
parent | 94c4d5b54e7840fa36d76e7c3d52e19c31a1dbc1 (diff) |
Merge branch 'master' into refactorEagerSolverrefactorEagerSolver
Diffstat (limited to 'test/unit/api/cpp/solver_white.cpp')
-rw-r--r-- | test/unit/api/cpp/solver_white.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/unit/api/cpp/solver_white.cpp b/test/unit/api/cpp/solver_white.cpp new file mode 100644 index 000000000..5d7b9eacf --- /dev/null +++ b/test/unit/api/cpp/solver_white.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** + * Top contributors (to current version): + * Aina Niemetz, Makai Mann, Andrew Reynolds + * + * This file is part of the cvc5 project. + * + * Copyright (c) 2009-2021 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. + * **************************************************************************** + * + * Black box testing of the Solver class of the C++ API. + */ + +#include "base/configuration.h" +#include "test_api.h" + +namespace cvc5 { + +using namespace api; + +namespace test { + +class TestApiWhiteSolver : public TestApi +{ +}; + +TEST_F(TestApiWhiteSolver, getOp) +{ + DatatypeDecl consListSpec = d_solver.mkDatatypeDecl("list"); + DatatypeConstructorDecl cons = d_solver.mkDatatypeConstructorDecl("cons"); + cons.addSelector("head", d_solver.getIntegerSort()); + cons.addSelectorSelf("tail"); + consListSpec.addConstructor(cons); + DatatypeConstructorDecl nil = d_solver.mkDatatypeConstructorDecl("nil"); + consListSpec.addConstructor(nil); + Sort consListSort = d_solver.mkDatatypeSort(consListSpec); + Datatype consList = consListSort.getDatatype(); + + Term nilTerm = consList.getConstructorTerm("nil"); + Term consTerm = consList.getConstructorTerm("cons"); + Term headTerm = consList["cons"].getSelectorTerm("head"); + + Term listnil = d_solver.mkTerm(APPLY_CONSTRUCTOR, nilTerm); + Term listcons1 = d_solver.mkTerm( + APPLY_CONSTRUCTOR, consTerm, d_solver.mkInteger(1), listnil); + Term listhead = d_solver.mkTerm(APPLY_SELECTOR, headTerm, listcons1); + + ASSERT_EQ(listnil.getOp(), Op(&d_solver, APPLY_CONSTRUCTOR)); + ASSERT_EQ(listcons1.getOp(), Op(&d_solver, APPLY_CONSTRUCTOR)); + ASSERT_EQ(listhead.getOp(), Op(&d_solver, APPLY_SELECTOR)); +} + +} // namespace test +} // namespace cvc5 |