LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/api/cpp - reset_assertions.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 22 100.0 %
Date: 2026-08-17 10:31:59 Functions: 1 1 100.0 %
Branches: 0 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                 :            :  * A simple test for cvc5::Solver::resetAssertions()
      11                 :            :  *
      12                 :            :  * This indirectly also tests some corner cases w.r.t. context-dependent
      13                 :            :  * datastructures: resetAssertions() pops the contexts to zero but some
      14                 :            :  * context-dependent datastructures are created at level 1, which the
      15                 :            :  * datastructure needs to handle properly problematic.
      16                 :            :  */
      17                 :            : 
      18                 :            : #include <cvc5/cvc5.h>
      19                 :            : 
      20                 :            : #include <iostream>
      21                 :            : #include <sstream>
      22                 :            : 
      23                 :            : using namespace cvc5;
      24                 :            : 
      25                 :          1 : int main()
      26                 :            : {
      27                 :          1 :   TermManager tm;
      28                 :          1 :   Solver slv(tm);
      29                 :          1 :   slv.setOption("incremental", "true");
      30                 :            : 
      31                 :          1 :   Sort real = tm.getRealSort();
      32                 :          1 :   Term x = tm.mkConst(real, "x");
      33                 :          1 :   Term four = tm.mkReal(4);
      34                 :          4 :   Term xEqFour = tm.mkTerm(Kind::EQUAL, {x, four});
      35                 :          1 :   slv.assertFormula(xEqFour);
      36                 :          1 :   std::cout << slv.checkSat() << std::endl;
      37                 :            : 
      38                 :          1 :   slv.resetAssertions();
      39                 :            : 
      40                 :          1 :   Sort elementType = tm.getIntegerSort();
      41                 :          1 :   Sort indexType = tm.getIntegerSort();
      42                 :          1 :   Sort arrayType = tm.mkArraySort(indexType, elementType);
      43                 :          1 :   Term array = tm.mkConst(arrayType, "array");
      44                 :          1 :   Term fourInt = tm.mkInteger(4);
      45                 :          4 :   Term arrayAtFour = tm.mkTerm(Kind::SELECT, {array, fourInt});
      46                 :          1 :   Term ten = tm.mkInteger(10);
      47                 :          4 :   Term arrayAtFour_eq_ten = tm.mkTerm(Kind::EQUAL, {arrayAtFour, ten});
      48                 :          1 :   slv.assertFormula(arrayAtFour_eq_ten);
      49                 :          1 :   std::cout << slv.checkSat() << std::endl;
      50                 :          1 : }

Generated by: LCOV version 1.14