LCOV - code coverage report
Current view: top level - src/test - util_check_tests.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 100.0 % 12 12
Test Date: 2025-10-25 05:06:34 Functions: 100.0 % 4 4
Branches: 45.8 % 168 77

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <util/check.h>
       6                 :             : 
       7                 :             : #include <boost/test/unit_test.hpp>
       8                 :             : #include <test/util/setup_common.h>
       9                 :             : 
      10                 :             : BOOST_AUTO_TEST_SUITE(util_check_tests)
      11                 :             : 
      12   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(check_pass)
          +  -  +  -  -  
          +  +  -  +  -  
          +  -  +  -  +  
          -  -  +  +  -  
          +  -  +  -  +  
          -  +  -  -  +  
          +  -  +  -  +  
          -  +  -  +  -  
          -  +  +  -  +  
          -  +  -  +  -  
          +  -  -  +  +  
                      - ]
      13                 :             : {
      14                 :           1 :     Assume(true);
      15                 :           1 :     Assert(true);
      16                 :           1 :     CHECK_NONFATAL(true);
      17                 :           1 : }
      18                 :             : 
      19   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(check_fail)
          +  -  +  -  -  
          +  +  -  +  -  
          +  -  +  -  +  
          -  -  +  +  -  
          +  -  +  -  +  
          -  +  -  -  +  
          +  -  +  -  +  
          -  +  -  +  -  
          -  +  +  -  +  
          -  +  -  +  -  
          +  -  -  +  +  
                      - ]
      20                 :             : {
      21                 :             :     // Disable aborts for easier testing here
      22         [ +  - ]:           1 :     test_only_CheckFailuresAreExceptionsNotAborts mock_checks{};
      23                 :             : 
      24                 :           1 :     if constexpr (G_ABORT_ON_FAILED_ASSUME) {
      25                 :             :         BOOST_CHECK_EXCEPTION(Assume(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
      26                 :             :     } else {
      27   [ +  -  +  -  :           2 :         BOOST_CHECK_NO_THROW(Assume(false));
          -  -  -  -  -  
                      - ]
      28                 :             :     }
      29   [ +  -  -  +  :           2 :     BOOST_CHECK_EXCEPTION(Assert(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
          -  -  -  -  -  
          +  +  -  +  -  
             +  -  +  - ]
      30   [ +  -  -  +  :           2 :     BOOST_CHECK_EXCEPTION(CHECK_NONFATAL(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
          -  -  -  -  -  
          +  +  -  +  -  
             +  -  +  - ]
      31                 :           1 : }
      32                 :             : 
      33                 :             : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1