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 cvc5::Configuration.
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 TestUtilWhite : public TestInternal
23 : : {
24 : : };
25 : :
26 : 4 : TEST_F(TestUtilWhite, Assert)
27 : : {
28 : : #ifdef CVC5_ASSERTIONS
29 : 1 : ASSERT_DEATH(Assert(false), "false");
30 : : #else
31 : : ASSERT_NO_THROW(Assert(false));
32 : : #endif
33 : 1 : ASSERT_DEATH(AlwaysAssert(false), "false");
34 [ + - ][ - + ]: 1 : ASSERT_NO_FATAL_FAILURE(Assert(true));
[ + - ]
35 [ + - ][ - + ]: 1 : ASSERT_NO_FATAL_FAILURE(AlwaysAssert(true));
[ + - ]
36 : : }
37 : :
38 : 4 : TEST_F(TestUtilWhite, AssertArgument)
39 : : {
40 : : #ifdef CVC5_ASSERTIONS
41 : 1 : ASSERT_THROW(AssertArgument(false, "x"), AssertArgumentException);
42 : : #else
43 : : ASSERT_NO_THROW(AssertArgument(false, "x"));
44 : : #endif
45 : 1 : ASSERT_THROW(AlwaysAssertArgument(false, "x"), AssertArgumentException);
46 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(AssertArgument(true, "x"));
[ - - ]
47 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(AssertArgument(true, "x"));
[ - - ]
48 : : }
49 : :
50 : 4 : TEST_F(TestUtilWhite, Unreachable)
51 : : {
52 : 1 : ASSERT_DEATH(Unreachable(), "Unreachable code reached ");
53 : 1 : ASSERT_DEATH(Unreachable() << "hello", "Unreachable code reached hello");
54 : 1 : ASSERT_DEATH(Unreachable() << "hello "
55 : : << "world",
56 : : "Unreachable code reached hello world");
57 : : }
58 : :
59 : 4 : TEST_F(TestUtilWhite, Unhandled)
60 : : {
61 : 1 : ASSERT_DEATH(Unhandled(), "Unhandled case encountered ");
62 : 1 : ASSERT_DEATH(Unhandled() << 5, "Unhandled case encountered 5");
63 : 1 : ASSERT_DEATH(Unhandled() << "foo", "Unhandled case encountered foo");
64 : 1 : ASSERT_DEATH(Unhandled() << "foo "
65 : : << "bar"
66 : : << " baz",
67 : : "Unhandled case encountered foo bar baz");
68 : : }
69 : :
70 : 4 : TEST_F(TestUtilWhite, Unimplemented)
71 : : {
72 : 1 : ASSERT_DEATH(Unimplemented(), "Unimplemented code encountered ");
73 : : }
74 : :
75 : 4 : TEST_F(TestUtilWhite, IllegalArgument)
76 : : {
77 : 1 : ASSERT_THROW(IllegalArgument("x"), IllegalArgumentException);
78 : : }
79 : :
80 : 4 : TEST_F(TestUtilWhite, CheckArgument)
81 : : {
82 : 1 : ASSERT_THROW(CheckArgument(false, "x"), IllegalArgumentException);
83 : : }
84 : : } // namespace test
85 : : } // namespace cvc5::internal
|