blob: 1ebc94b75c0b8cb57ea9c8faf2c3b9f8fa79ddec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/******************************************************************************
* Top contributors (to current version):
* Aina Niemetz, Morgan Deters
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Black box testing of cvc5::Exception.
*/
#include <iostream>
#include <sstream>
#include "base/exception.h"
#include "test.h"
namespace cvc5 {
namespace test {
class TestUtilBlackException : public TestInternal
{
};
// cvc5::Exception is a simple class, just test it all at once.
TEST_F(TestUtilBlackException, exceptions)
{
Exception e1;
Exception e2(std::string("foo!"));
Exception e3("bar!");
ASSERT_EQ(e1.toString(), std::string("Unknown exception"));
ASSERT_EQ(e2.toString(), std::string("foo!"));
ASSERT_EQ(e3.toString(), std::string("bar!"));
e1.setMessage("blah");
e2.setMessage("another");
e3.setMessage("three of 'em!");
std::stringstream s1, s2, s3;
s1 << e1;
s2 << e2;
s3 << e3;
ASSERT_EQ(s1.str(), std::string("blah"));
ASSERT_EQ(s2.str(), std::string("another"));
ASSERT_EQ(s3.str(), std::string("three of 'em!"));
}
} // namespace test
} // namespace cvc5
|