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