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