GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/theory/theory_white.cpp Lines: 40 40 100.0 %
Date: 2021-08-17 Branches: 66 228 28.9 %

Line Exec Source
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_TRUE(Theory::standardEffortOnly(s));
65
2
  ASSERT_FALSE(Theory::standardEffortOnly(f));
66
67
2
  ASSERT_FALSE(Theory::fullEffort(s));
68
2
  ASSERT_TRUE(Theory::fullEffort(f));
69
70
2
  ASSERT_TRUE(Theory::standardEffortOrMore(s));
71
2
  ASSERT_TRUE(Theory::standardEffortOrMore(f));
72
}
73
74
12
TEST_F(TestTheoryWhite, done)
75
{
76
2
  ASSERT_TRUE(d_dummy_theory->done());
77
78
2
  d_dummy_theory->assertFact(d_atom0, true);
79
2
  d_dummy_theory->assertFact(d_atom1, true);
80
81
2
  ASSERT_FALSE(d_dummy_theory->done());
82
83
2
  d_dummy_theory->check(Theory::EFFORT_FULL);
84
85
2
  ASSERT_TRUE(d_dummy_theory->done());
86
}
87
88
12
TEST_F(TestTheoryWhite, outputChannel)
89
{
90
4
  Node n = d_atom0.orNode(d_atom1);
91
2
  d_outputChannel.lemma(n);
92
2
  d_outputChannel.lemma(d_atom0.orNode(d_atom0.notNode()));
93
4
  Node s = d_atom0.orNode(d_atom0.notNode());
94
2
  ASSERT_EQ(d_outputChannel.d_callHistory.size(), 2u);
95
2
  ASSERT_EQ(d_outputChannel.d_callHistory[0], std::make_pair(LEMMA, n));
96
2
  ASSERT_EQ(d_outputChannel.d_callHistory[1], std::make_pair(LEMMA, s));
97
2
  d_outputChannel.d_callHistory.clear();
98
}
99
}  // namespace test
100
40186
}  // namespace cvc5