1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Morgan Deters |
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 |
|
* Black box testing of cvc5::Exception. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <iostream> |
17 |
|
#include <sstream> |
18 |
|
|
19 |
|
#include "base/exception.h" |
20 |
|
#include "test.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace test { |
24 |
|
|
25 |
4 |
class TestUtilBlackException : public TestInternal |
26 |
|
{ |
27 |
|
}; |
28 |
|
|
29 |
|
// cvc5::Exception is a simple class, just test it all at once. |
30 |
10 |
TEST_F(TestUtilBlackException, exceptions) |
31 |
|
{ |
32 |
4 |
Exception e1; |
33 |
4 |
Exception e2(std::string("foo!")); |
34 |
4 |
Exception e3("bar!"); |
35 |
|
|
36 |
2 |
ASSERT_EQ(e1.toString(), std::string("Unknown exception")); |
37 |
2 |
ASSERT_EQ(e2.toString(), std::string("foo!")); |
38 |
2 |
ASSERT_EQ(e3.toString(), std::string("bar!")); |
39 |
|
|
40 |
2 |
e1.setMessage("blah"); |
41 |
2 |
e2.setMessage("another"); |
42 |
2 |
e3.setMessage("three of 'em!"); |
43 |
|
|
44 |
4 |
std::stringstream s1, s2, s3; |
45 |
2 |
s1 << e1; |
46 |
2 |
s2 << e2; |
47 |
2 |
s3 << e3; |
48 |
|
|
49 |
2 |
ASSERT_EQ(s1.str(), std::string("blah")); |
50 |
2 |
ASSERT_EQ(s2.str(), std::string("another")); |
51 |
2 |
ASSERT_EQ(s3.str(), std::string("three of 'em!")); |
52 |
|
} |
53 |
|
} // namespace test |
54 |
6 |
} // namespace cvc5 |