blob: 7219ce0804d029397640095e6b33eba19604ddd7 (
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
55
|
/********************* */
/*! \file exception_black.cpp
** \verbatim
** Top contributors (to current version):
** Aina Niemetz, Morgan Deters
** This file is part of the CVC4 project.
** Copyright (c) 2009-2020 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.\endverbatim
**
** \brief Black box testing of CVC4::Exception.
**
** Black box testing of CVC4::Exception.
**/
#include <iostream>
#include <sstream>
#include "base/exception.h"
#include "test.h"
namespace CVC4 {
namespace test {
class TestUtilBlackException : public TestInternal
{
};
// CVC4::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 CVC4
|