LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/unit/theory - theory_white.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 38 100.0 %
Date: 2026-09-16 10:08:14 Functions: 13 13 100.0 %
Branches: 20 40 50.0 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * Black box testing of cvc5::theory::Theory.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include <memory>
      14                 :            : #include <vector>
      15                 :            : 
      16                 :            : #include "context/context.h"
      17                 :            : #include "expr/node.h"
      18                 :            : #include "smt/smt_solver.h"
      19                 :            : #include "test_smt.h"
      20                 :            : #include "theory/theory.h"
      21                 :            : #include "theory/theory_engine.h"
      22                 :            : #include "util/resource_manager.h"
      23                 :            : 
      24                 :            : namespace cvc5::internal {
      25                 :            : 
      26                 :            : using namespace theory;
      27                 :            : using namespace expr;
      28                 :            : using namespace context;
      29                 :            : 
      30                 :            : namespace test {
      31                 :            : 
      32                 :            : class TestTheoryWhite : public TestSmtNoFinishInit
      33                 :            : {
      34                 :            :  protected:
      35                 :          3 :   void SetUp() override
      36                 :            :   {
      37                 :          3 :     TestSmtNoFinishInit::SetUp();
      38                 :          3 :     d_slvEngine->finishInit();
      39                 :          3 :     TheoryEngine* te = d_slvEngine->d_smtSolver->getTheoryEngine();
      40         [ +  - ]:          3 :     delete te->d_theoryTable[THEORY_BUILTIN];
      41         [ +  - ]:          3 :     delete te->d_theoryOut[THEORY_BUILTIN];
      42                 :          3 :     te->d_theoryTable[THEORY_BUILTIN] = nullptr;
      43                 :          3 :     te->d_theoryOut[THEORY_BUILTIN] = nullptr;
      44                 :          3 :     Env& env = d_slvEngine->getEnv();
      45                 :          6 :     d_outputChannel.reset(
      46                 :          6 :         new DummyOutputChannel(env.getStatisticsRegistry(), te, "Dummy"));
      47                 :          3 :     d_dummy_theory.reset(new DummyTheory<THEORY_BUILTIN>(
      48                 :          3 :         env, *d_outputChannel.get(), Valuation(nullptr)));
      49                 :          3 :     d_atom0 = d_nodeManager->mkConst(true);
      50                 :          3 :     d_atom1 = d_nodeManager->mkConst(false);
      51                 :          3 :   }
      52                 :            : 
      53                 :            :   std::unique_ptr<DummyOutputChannel> d_outputChannel;
      54                 :            :   std::unique_ptr<DummyTheory<THEORY_BUILTIN>> d_dummy_theory;
      55                 :            :   Node d_atom0;
      56                 :            :   Node d_atom1;
      57                 :            : };
      58                 :            : 
      59                 :          4 : TEST_F(TestTheoryWhite, effort)
      60                 :            : {
      61                 :          1 :   Theory::Effort s = Theory::EFFORT_STANDARD;
      62                 :          1 :   Theory::Effort f = Theory::EFFORT_FULL;
      63                 :            : 
      64 [ -  + ][ +  - ]:          1 :   ASSERT_FALSE(Theory::fullEffort(s));
      65 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(Theory::fullEffort(f));
      66                 :            : }
      67                 :            : 
      68                 :          4 : TEST_F(TestTheoryWhite, done)
      69                 :            : {
      70 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(d_dummy_theory->done());
      71                 :            : 
      72                 :          1 :   d_dummy_theory->assertFact(d_atom0, true);
      73                 :          1 :   d_dummy_theory->assertFact(d_atom1, true);
      74                 :            : 
      75 [ -  + ][ +  - ]:          1 :   ASSERT_FALSE(d_dummy_theory->done());
      76                 :            : 
      77                 :          1 :   d_dummy_theory->check(Theory::EFFORT_FULL);
      78                 :            : 
      79 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(d_dummy_theory->done());
      80                 :            : }
      81                 :            : 
      82                 :          4 : TEST_F(TestTheoryWhite, outputChannel)
      83                 :            : {
      84                 :          1 :   Node n = d_atom0.orNode(d_atom1);
      85                 :          1 :   d_outputChannel->lemma(n, theory::InferenceId::NONE);
      86                 :          1 :   d_outputChannel->lemma(d_atom0.orNode(d_atom0.notNode()),
      87                 :            :                          theory::InferenceId::NONE);
      88                 :          1 :   Node s = d_atom0.orNode(d_atom0.notNode());
      89 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(d_outputChannel->d_callHistory.size(), 2u);
      90 [ -  + ][ +  - ]:          2 :   ASSERT_EQ(d_outputChannel->d_callHistory[0], std::make_pair(LEMMA, n));
      91 [ -  + ][ +  - ]:          2 :   ASSERT_EQ(d_outputChannel->d_callHistory[1], std::make_pair(LEMMA, s));
      92                 :          1 :   d_outputChannel->d_callHistory.clear();
      93 [ +  - ][ +  - ]:          1 : }
      94                 :            : }  // namespace test
      95                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14