OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TestOpalException.cpp
Go to the documentation of this file.
6
7#include <gtest/gtest.h>
8
9TEST(OpalExceptionTest, StoresLocationAndMessage) {
10 OpalException ex("method", "message");
11
12 EXPECT_EQ(ex.where(), "method");
13 EXPECT_EQ(ex.what(), "message");
14}
15
16TEST(OpalExceptionTest, CopyPreservesLocationAndMessage) {
17 OpalException ex("method", "message");
18 OpalException copy(ex);
19
20 EXPECT_EQ(copy.where(), "method");
21 EXPECT_EQ(copy.what(), "message");
22}
23
24TEST(OpalExceptionTest, GenericExceptionIsCaughtAsOpalException) {
25 try {
26 throw GeneralOpalException("generic", "failure");
27 } catch (const OpalException& ex) {
28 EXPECT_EQ(ex.where(), "generic");
29 EXPECT_EQ(ex.what(), "failure");
30 return;
31 }
32
33 FAIL() << "GeneralOpalException was not caught as OpalException";
34}
35
36TEST(OpalExceptionTest, ParserExceptionsAreCaughtAsOpalException) {
37 EXPECT_THROW(throw ParseError("parse", "bad token"), OpalException);
38 EXPECT_THROW(throw SDDSParserException("sdds", "bad column"), OpalException);
39}
40
41TEST(OpalExceptionTest, ArithmeticDerivedExceptionsAreCaughtAsOpalException) {
42 EXPECT_THROW(throw DomainError("domain"), OpalException);
43}
TEST(OpalExceptionTest, StoresLocationAndMessage)
Domain error exception.
Definition DomainError.h:32
virtual const std::string & what() const
Return the message string for the exception.
virtual const std::string & where() const
Return the name of the method or function which detected the exception.
Parse exception.
Definition ParseError.h:31