GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/util/assert_white.cpp Lines: 27 27 100.0 %
Date: 2021-03-23 Branches: 179 768 23.3 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file assert_white.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Aina Niemetz
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief White box testing of CVC4::Configuration.
13
 **
14
 ** White box testing of CVC4::Configuration.
15
 **/
16
17
#include <cstring>
18
#include <string>
19
20
#include "base/check.h"
21
#include "test.h"
22
23
namespace CVC4 {
24
namespace test {
25
26
28
class TestUtilWhite : public TestInternal
27
{
28
};
29
30
16
TEST_F(TestUtilWhite, Assert)
31
{
32
#ifdef CVC4_ASSERTIONS
33
2
  ASSERT_DEATH(Assert(false), "false");
34
#else
35
  ASSERT_NO_THROW(Assert(false));
36
#endif
37
2
  ASSERT_DEATH(AlwaysAssert(false), "false");
38
2
  ASSERT_NO_FATAL_FAILURE(Assert(true));
39
2
  ASSERT_NO_FATAL_FAILURE(AlwaysAssert(true));
40
}
41
42
16
TEST_F(TestUtilWhite, AssertArgument)
43
{
44
#ifdef CVC4_ASSERTIONS
45
2
  ASSERT_THROW(AssertArgument(false, "x"), AssertArgumentException);
46
#else
47
  ASSERT_NO_THROW(AssertArgument(false, "x"));
48
#endif
49
2
  ASSERT_THROW(AlwaysAssertArgument(false, "x"), AssertArgumentException);
50
2
  ASSERT_NO_THROW(AssertArgument(true, "x"));
51
2
  ASSERT_NO_THROW(AssertArgument(true, "x"));
52
}
53
54
16
TEST_F(TestUtilWhite, Unreachable)
55
{
56
2
  ASSERT_DEATH(Unreachable(), "Unreachable code reached");
57
2
  ASSERT_DEATH(Unreachable() << "hello", "Unreachable code reachedhello");
58
2
  ASSERT_DEATH(Unreachable() << "hello "
59
                             << "world",
60
               "Unreachable code reachedhello world");
61
}
62
63
16
TEST_F(TestUtilWhite, Unhandled)
64
{
65
2
  ASSERT_DEATH(Unhandled(), "Unhandled case encountered");
66
2
  ASSERT_DEATH(Unhandled() << 5, "Unhandled case encountered5");
67
2
  ASSERT_DEATH(Unhandled() << "foo", "Unhandled case encounteredfoo");
68
2
  ASSERT_DEATH(Unhandled() << "foo "
69
                           << "bar"
70
                           << " baz",
71
               "Unhandled case encounteredfoo bar baz");
72
}
73
74
16
TEST_F(TestUtilWhite, Unimplemented)
75
{
76
2
  ASSERT_DEATH(Unimplemented(), "Unimplemented code encountered");
77
}
78
79
16
TEST_F(TestUtilWhite, IllegalArgument)
80
{
81
2
  ASSERT_THROW(IllegalArgument("x"), IllegalArgumentException);
82
}
83
84
16
TEST_F(TestUtilWhite, CheckArgument)
85
{
86
2
  ASSERT_THROW(CheckArgument(false, "x"), IllegalArgumentException);
87
}
88
}  // namespace test
89
24
}  // namespace CVC4