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/options.h" |
22 |
|
#include "options/set_language.h" |
23 |
|
#include "parser/parser.h" |
24 |
|
#include "parser/parser_builder.h" |
25 |
|
#include "smt/command.h" |
26 |
|
#include "smt/smt_engine.h" |
27 |
|
|
28 |
|
using namespace cvc5; |
29 |
|
using namespace cvc5::parser; |
30 |
|
using namespace std; |
31 |
|
|
32 |
|
void testGetInfo(api::Solver* solver, const char* s); |
33 |
|
|
34 |
1 |
int main() |
35 |
|
{ |
36 |
1 |
cout << language::SetLanguage(Language::LANG_SMTLIB_V2_6); |
37 |
|
|
38 |
2 |
std::unique_ptr<api::Solver> solver = std::make_unique<api::Solver>(); |
39 |
1 |
solver->setOption("input-language", "smtlib2"); |
40 |
1 |
solver->setOption("output-language", "smtlib2"); |
41 |
1 |
testGetInfo(solver.get(), ":error-behavior"); |
42 |
1 |
testGetInfo(solver.get(), ":name"); |
43 |
1 |
testGetInfo(solver.get(), ":authors"); |
44 |
1 |
testGetInfo(solver.get(), ":version"); |
45 |
1 |
testGetInfo(solver.get(), ":status"); |
46 |
1 |
testGetInfo(solver.get(), ":reason-unknown"); |
47 |
1 |
testGetInfo(solver.get(), ":arbitrary-undefined-keyword"); |
48 |
1 |
testGetInfo(solver.get(), ":56"); // legal |
49 |
1 |
testGetInfo(solver.get(), ":<="); // legal |
50 |
1 |
testGetInfo(solver.get(), ":->"); // legal |
51 |
1 |
testGetInfo(solver.get(), ":all-statistics"); |
52 |
|
|
53 |
1 |
return 0; |
54 |
|
} |
55 |
|
|
56 |
11 |
void testGetInfo(api::Solver* solver, const char* s) |
57 |
|
{ |
58 |
22 |
std::unique_ptr<SymbolManager> symman(new SymbolManager(solver)); |
59 |
|
|
60 |
22 |
std::unique_ptr<Parser> p(ParserBuilder(solver, symman.get(), true).build()); |
61 |
33 |
p->setInput(Input::newStringInput( |
62 |
22 |
"LANG_SMTLIB_V2_6", string("(get-info ") + s + ")", "<internal>")); |
63 |
11 |
assert(p != NULL); |
64 |
11 |
Command* c = p->nextCommand(); |
65 |
11 |
assert(c != NULL); |
66 |
11 |
cout << c << endl; |
67 |
22 |
stringstream ss; |
68 |
11 |
c->invoke(solver, symman.get(), ss); |
69 |
11 |
assert(p->nextCommand() == NULL); |
70 |
11 |
delete c; |
71 |
11 |
cout << ss.str() << endl << endl; |
72 |
14 |
} |