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 |
2 |
Options opts; |
39 |
1 |
opts.base.inputLanguage = language::input::LANG_SMTLIB_V2; |
40 |
1 |
opts.base.outputLanguage = language::output::LANG_SMTLIB_V2; |
41 |
|
|
42 |
1 |
cout << language::SetLanguage(language::output::LANG_SMTLIB_V2); |
43 |
|
|
44 |
|
std::unique_ptr<api::Solver> solver = |
45 |
2 |
std::unique_ptr<api::Solver>(new api::Solver(&opts)); |
46 |
1 |
testGetInfo(solver.get(), ":error-behavior"); |
47 |
1 |
testGetInfo(solver.get(), ":name"); |
48 |
1 |
testGetInfo(solver.get(), ":authors"); |
49 |
1 |
testGetInfo(solver.get(), ":version"); |
50 |
1 |
testGetInfo(solver.get(), ":status"); |
51 |
1 |
testGetInfo(solver.get(), ":reason-unknown"); |
52 |
1 |
testGetInfo(solver.get(), ":arbitrary-undefined-keyword"); |
53 |
1 |
testGetInfo(solver.get(), ":56"); // legal |
54 |
1 |
testGetInfo(solver.get(), ":<="); // legal |
55 |
1 |
testGetInfo(solver.get(), ":->"); // legal |
56 |
1 |
testGetInfo(solver.get(), ":all-statistics"); |
57 |
|
|
58 |
1 |
return 0; |
59 |
|
} |
60 |
|
|
61 |
11 |
void testGetInfo(api::Solver* solver, const char* s) |
62 |
|
{ |
63 |
22 |
std::unique_ptr<SymbolManager> symman(new SymbolManager(solver)); |
64 |
|
|
65 |
|
std::unique_ptr<Parser> p( |
66 |
22 |
ParserBuilder(solver, symman.get(), solver->getOptions()).build()); |
67 |
33 |
p->setInput(Input::newStringInput(language::input::LANG_SMTLIB_V2, |
68 |
22 |
string("(get-info ") + s + ")", |
69 |
|
"<internal>")); |
70 |
11 |
assert(p != NULL); |
71 |
11 |
Command* c = p->nextCommand(); |
72 |
11 |
assert(c != NULL); |
73 |
11 |
cout << c << endl; |
74 |
22 |
stringstream ss; |
75 |
11 |
c->invoke(solver, symman.get(), ss); |
76 |
11 |
assert(p->nextCommand() == NULL); |
77 |
11 |
delete c; |
78 |
11 |
cout << ss.str() << endl << endl; |
79 |
14 |
} |