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