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_context = d_smtEngine->getContext(); |
41 |
6 |
d_user_context = d_smtEngine->getUserContext(); |
42 |
6 |
d_logicInfo.reset(new LogicInfo()); |
43 |
6 |
d_logicInfo->lock(); |
44 |
6 |
d_smtEngine->finishInit(); |
45 |
6 |
delete d_smtEngine->getTheoryEngine()->d_theoryTable[THEORY_BUILTIN]; |
46 |
6 |
delete d_smtEngine->getTheoryEngine()->d_theoryOut[THEORY_BUILTIN]; |
47 |
6 |
d_smtEngine->getTheoryEngine()->d_theoryTable[THEORY_BUILTIN] = nullptr; |
48 |
6 |
d_smtEngine->getTheoryEngine()->d_theoryOut[THEORY_BUILTIN] = nullptr; |
49 |
|
|
50 |
18 |
d_dummy_theory.reset(new DummyTheory<THEORY_BUILTIN>(d_context, |
51 |
|
d_user_context, |
52 |
|
d_outputChannel, |
53 |
12 |
Valuation(nullptr), |
54 |
6 |
*d_logicInfo, |
55 |
6 |
nullptr)); |
56 |
6 |
d_outputChannel.clear(); |
57 |
6 |
d_atom0 = d_nodeManager->mkConst(true); |
58 |
6 |
d_atom1 = d_nodeManager->mkConst(false); |
59 |
6 |
} |
60 |
|
|
61 |
|
Context* d_context; |
62 |
|
UserContext* d_user_context; |
63 |
|
std::unique_ptr<LogicInfo> d_logicInfo; |
64 |
|
DummyOutputChannel d_outputChannel; |
65 |
|
std::unique_ptr<DummyTheory<THEORY_BUILTIN>> d_dummy_theory; |
66 |
|
Node d_atom0; |
67 |
|
Node d_atom1; |
68 |
|
}; |
69 |
|
|
70 |
12 |
TEST_F(TestTheoryWhite, effort) |
71 |
|
{ |
72 |
2 |
Theory::Effort s = Theory::EFFORT_STANDARD; |
73 |
2 |
Theory::Effort f = Theory::EFFORT_FULL; |
74 |
|
|
75 |
2 |
ASSERT_TRUE(Theory::standardEffortOnly(s)); |
76 |
2 |
ASSERT_FALSE(Theory::standardEffortOnly(f)); |
77 |
|
|
78 |
2 |
ASSERT_FALSE(Theory::fullEffort(s)); |
79 |
2 |
ASSERT_TRUE(Theory::fullEffort(f)); |
80 |
|
|
81 |
2 |
ASSERT_TRUE(Theory::standardEffortOrMore(s)); |
82 |
2 |
ASSERT_TRUE(Theory::standardEffortOrMore(f)); |
83 |
|
} |
84 |
|
|
85 |
12 |
TEST_F(TestTheoryWhite, done) |
86 |
|
{ |
87 |
2 |
ASSERT_TRUE(d_dummy_theory->done()); |
88 |
|
|
89 |
2 |
d_dummy_theory->assertFact(d_atom0, true); |
90 |
2 |
d_dummy_theory->assertFact(d_atom1, true); |
91 |
|
|
92 |
2 |
ASSERT_FALSE(d_dummy_theory->done()); |
93 |
|
|
94 |
2 |
d_dummy_theory->check(Theory::EFFORT_FULL); |
95 |
|
|
96 |
2 |
ASSERT_TRUE(d_dummy_theory->done()); |
97 |
|
} |
98 |
|
|
99 |
12 |
TEST_F(TestTheoryWhite, outputChannel) |
100 |
|
{ |
101 |
4 |
Node n = d_atom0.orNode(d_atom1); |
102 |
2 |
d_outputChannel.lemma(n); |
103 |
2 |
d_outputChannel.lemma(d_atom0.orNode(d_atom0.notNode())); |
104 |
4 |
Node s = d_atom0.orNode(d_atom0.notNode()); |
105 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory.size(), 2u); |
106 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory[0], std::make_pair(LEMMA, n)); |
107 |
2 |
ASSERT_EQ(d_outputChannel.d_callHistory[1], std::make_pair(LEMMA, s)); |
108 |
2 |
d_outputChannel.d_callHistory.clear(); |
109 |
|
} |
110 |
|
} // namespace test |
111 |
40186 |
} // namespace cvc5 |