1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Dejan Jovanovic |
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 |
|
* Black box testing of cvc5::theory::Theory. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <memory> |
17 |
|
#include <vector> |
18 |
|
|
19 |
|
#include "context/context.h" |
20 |
|
#include "expr/node.h" |
21 |
|
#include "test_smt.h" |
22 |
|
#include "theory/theory.h" |
23 |
|
#include "theory/theory_engine.h" |
24 |
|
#include "util/resource_manager.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
|
using namespace theory; |
29 |
|
using namespace expr; |
30 |
|
using namespace context; |
31 |
|
|
32 |
|
namespace test { |
33 |
|
|
34 |
12 |
class TestTheoryWhite : public TestSmtNoFinishInit |
35 |
|
{ |
36 |
|
protected: |
37 |
6 |
void SetUp() override |
38 |
|
{ |
39 |
6 |
TestSmtNoFinishInit::SetUp(); |
40 |
6 |
d_smtEngine->finishInit(); |
41 |
6 |
delete d_smtEngine->getTheoryEngine()->d_theoryTable[THEORY_BUILTIN]; |
42 |
6 |
delete d_smtEngine->getTheoryEngine()->d_theoryOut[THEORY_BUILTIN]; |
43 |
6 |
d_smtEngine->getTheoryEngine()->d_theoryTable[THEORY_BUILTIN] = nullptr; |
44 |
6 |
d_smtEngine->getTheoryEngine()->d_theoryOut[THEORY_BUILTIN] = nullptr; |
45 |
|
|
46 |
18 |
d_dummy_theory.reset(new DummyTheory<THEORY_BUILTIN>( |
47 |
18 |
d_smtEngine->getEnv(), d_outputChannel, Valuation(nullptr))); |
48 |
6 |
d_outputChannel.clear(); |
49 |
6 |
d_atom0 = d_nodeManager->mkConst(true); |
50 |
6 |
d_atom1 = d_nodeManager->mkConst(false); |
51 |
6 |
} |
52 |
|
|
53 |
|
DummyOutputChannel d_outputChannel; |
54 |
|
std::unique_ptr<DummyTheory<THEORY_BUILTIN>> d_dummy_theory; |
55 |
|
Node d_atom0; |
56 |
|
Node d_atom1; |
57 |
|
}; |
58 |
|
|
59 |
12 |
TEST_F(TestTheoryWhite, effort) |
60 |
|
{ |
61 |
2 |
Theory::Effort s = Theory::EFFORT_STANDARD; |
62 |
2 |
Theory::Effort f = Theory::EFFORT_FULL; |
63 |
|
|
64 |
2 |
ASSERT_FALSE(Theory::fullEffort(s)); |
65 |
2 |
ASSERT_TRUE(Theory::fullEffort(f)); |
66 |
|
} |
67 |
|
|
68 |
12 |
TEST_F(TestTheoryWhite, done) |
69 |
|
{ |
70 |
2 |
ASSERT_TRUE(d_dummy_theory->done()); |
71 |
|
|
72 |
2 |
d_dummy_theory->assertFact(d_atom0, true); |
73 |
2 |
d_dummy_theory->assertFact(d_atom1, true); |
74 |
|
|
75 |
2 |
ASSERT_FALSE(d_dummy_theory->done()); |
76 |
|
|
77 |
2 |
d_dummy_theory->check(Theory::EFFORT_FULL); |
78 |
|
|
79 |
2 |
ASSERT_TRUE(d_dummy_theory->done()); |
80 |
|
} |
81 |
|
|
82 |
12 |
TEST_F(TestTheoryWhite, outputChannel) |
83 |
|
{ |
84 |
4 |
Node n = d_atom0.orNode(d_atom1); |
85 |
2 |
d_outputChannel.lemma(n); |
86 |
2 |
d_outputChannel.lemma(d_atom0.orNode(d_atom0.notNode())); |
87 |
4 |
Node s = d_atom0.orNode(d_atom0.notNode()); |
88 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory.size(), 2u); |
89 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory[0], std::make_pair(LEMMA, n)); |
90 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory[1], std::make_pair(LEMMA, s)); |
91 |
2 |
d_outputChannel.d_callHistory.clear(); |
92 |
|
} |
93 |
|
} // namespace test |
94 |
40156 |
} // namespace cvc5 |