1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Morgan Deters, Tim King |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* A test of SMT-LIBv2 commands, checks for compliant output. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <cassert> |
17 |
|
#include <iostream> |
18 |
|
#include <sstream> |
19 |
|
|
20 |
|
#include "api/cpp/cvc5.h" |
21 |
|
#include "options/base_options.h" |
22 |
|
#include "options/options.h" |
23 |
|
#include "options/options_public.h" |
24 |
|
#include "options/set_language.h" |
25 |
|
#include "parser/parser.h" |
26 |
|
#include "parser/parser_builder.h" |
27 |
|
#include "smt/command.h" |
28 |
|
#include "smt/smt_engine.h" |
29 |
|
|
30 |
|
using namespace cvc5; |
31 |
|
using namespace cvc5::parser; |
32 |
|
using namespace std; |
33 |
|
|
34 |
|
void testGetInfo(api::Solver* solver, const char* s); |
35 |
|
|
36 |
1 |
int main() |
37 |
|
{ |
38 |
1 |
cout << language::SetLanguage(language::output::LANG_SMTLIB_V2); |
39 |
|
|
40 |
2 |
std::unique_ptr<api::Solver> solver = std::make_unique<api::Solver>(); |
41 |
1 |
solver->setOption("input-language", "smtlib2"); |
42 |
1 |
solver->setOption("output-language", "smtlib2"); |
43 |
1 |
testGetInfo(solver.get(), ":error-behavior"); |
44 |
1 |
testGetInfo(solver.get(), ":name"); |
45 |
1 |
testGetInfo(solver.get(), ":authors"); |
46 |
1 |
testGetInfo(solver.get(), ":version"); |
47 |
1 |
testGetInfo(solver.get(), ":status"); |
48 |
1 |
testGetInfo(solver.get(), ":reason-unknown"); |
49 |
1 |
testGetInfo(solver.get(), ":arbitrary-undefined-keyword"); |
50 |
1 |
testGetInfo(solver.get(), ":56"); // legal |
51 |
1 |
testGetInfo(solver.get(), ":<="); // legal |
52 |
1 |
testGetInfo(solver.get(), ":->"); // legal |
53 |
1 |
testGetInfo(solver.get(), ":all-statistics"); |
54 |
|
|
55 |
1 |
return 0; |
56 |
|
} |
57 |
|
|
58 |
11 |
void testGetInfo(api::Solver* solver, const char* s) |
59 |
|
{ |
60 |
22 |
std::unique_ptr<SymbolManager> symman(new SymbolManager(solver)); |
61 |
|
|
62 |
|
std::unique_ptr<Parser> p( |
63 |
22 |
ParserBuilder(solver, symman.get(), solver->getOptions()).build()); |
64 |
33 |
p->setInput(Input::newStringInput(language::input::LANG_SMTLIB_V2, |
65 |
22 |
string("(get-info ") + s + ")", |
66 |
|
"<internal>")); |
67 |
11 |
assert(p != NULL); |
68 |
11 |
Command* c = p->nextCommand(); |
69 |
11 |
assert(c != NULL); |
70 |
11 |
cout << c << endl; |
71 |
22 |
stringstream ss; |
72 |
11 |
c->invoke(solver, symman.get(), ss); |
73 |
11 |
assert(p->nextCommand() == NULL); |
74 |
11 |
delete c; |
75 |
11 |
cout << ss.str() << endl << endl; |
76 |
14 |
} |