LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/unit/util - check_white.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2026-06-02 10:35:19 Functions: 16 16 100.0 %
Branches: 4 12 33.3 %

           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                 :            :  * White box testing of check utilities.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include <cstring>
      14                 :            : #include <string>
      15                 :            : 
      16                 :            : #include "base/check.h"
      17                 :            : #include "test.h"
      18                 :            : 
      19                 :            : namespace cvc5::internal {
      20                 :            : namespace test {
      21                 :            : 
      22                 :            : class TestUtilWhiteCheck : public TestInternal
      23                 :            : {
      24                 :            :  protected:
      25                 :            :   static constexpr uint32_t K_ONE = 1;
      26                 :            : 
      27                 :            :   // This test just checks that this statement compiles.
      28                 :            :   std::string terminalCvc5Fatal() const
      29                 :            :   {
      30                 :            :     CVC5_FATAL() << "This is a test that confirms that CVC5_FATAL can be a "
      31                 :            :                     "terminal statement in a function that has a non-void "
      32                 :            :                     "return type.";
      33                 :            :   }
      34                 :            : };
      35                 :            : 
      36                 :          4 : TEST_F(TestUtilWhiteCheck, check)
      37                 :            : {
      38                 :            :   AlwaysAssert(K_ONE >= 0) << K_ONE << " must be positive";
      39                 :          1 : }
      40                 :            : 
      41                 :          4 : TEST_F(TestUtilWhiteCheck, dcheck)
      42                 :            : {
      43                 :            :   Assert(K_ONE == 1) << "always passes";
      44                 :            : #ifndef CVC5_ASSERTIONS
      45                 :            :   Assert(false) << "Will not be compiled in when CVC5_ASSERTIONS off.";
      46                 :            : #endif
      47                 :          1 : }
      48                 :            : 
      49                 :          4 : TEST_F(TestUtilWhiteCheck, pointer_type_can_be_condition)
      50                 :            : {
      51                 :          1 :   const uint32_t* one_pointer = &K_ONE;
      52 [ -  + ][ -  + ]:          1 :   Assert(one_pointer);
                 [ -  - ]
      53 [ -  + ][ -  + ]:          1 :   AlwaysAssert(one_pointer);
                 [ -  - ]
      54                 :          1 : }
      55                 :            : 
      56                 :          4 : TEST_F(TestUtilWhiteCheck, expect_abort)
      57                 :            : {
      58                 :          1 :   ASSERT_DEATH(Assert(false), "false");
      59                 :          1 :   ASSERT_DEATH(AlwaysAssert(false), "false");
      60                 :            : }
      61                 :            : }  // namespace test
      62                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14