GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/util/check_white.cpp Lines: 16 16 100.0 %
Date: 2021-05-22 Branches: 34 174 19.5 %

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