OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TestOpalException.cpp
Go to the documentation of this file.
1
#include "
Utilities/DomainError.h
"
2
#include "
Utilities/GeneralOpalException.h
"
3
#include "
Utilities/OpalException.h
"
4
#include "
Utilities/ParseError.h
"
5
#include "
Utilities/SDDSParser/SDDSParserException.h
"
6
7
#include <gtest/gtest.h>
8
9
TEST
(OpalExceptionTest, StoresLocationAndMessage) {
10
OpalException
ex(
"method"
,
"message"
);
11
12
EXPECT_EQ(ex.
where
(),
"method"
);
13
EXPECT_EQ(ex.
what
(),
"message"
);
14
}
15
16
TEST
(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
24
TEST
(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
36
TEST
(OpalExceptionTest, ParserExceptionsAreCaughtAsOpalException) {
37
EXPECT_THROW(
throw
ParseError
(
"parse"
,
"bad token"
),
OpalException
);
38
EXPECT_THROW(
throw
SDDSParserException
(
"sdds"
,
"bad column"
),
OpalException
);
39
}
40
41
TEST
(OpalExceptionTest, ArithmeticDerivedExceptionsAreCaughtAsOpalException) {
42
EXPECT_THROW(
throw
DomainError
(
"domain"
),
OpalException
);
43
}
DomainError.h
GeneralOpalException.h
OpalException.h
ParseError.h
SDDSParserException.h
TEST
TEST(OpalExceptionTest, StoresLocationAndMessage)
Definition
TestOpalException.cpp:9
DomainError
Domain error exception.
Definition
DomainError.h:32
GeneralOpalException
Definition
GeneralOpalException.h:12
OpalException
Definition
OpalException.h:30
OpalException::what
virtual const std::string & what() const
Return the message string for the exception.
Definition
OpalException.cpp:31
OpalException::where
virtual const std::string & where() const
Return the name of the method or function which detected the exception.
Definition
OpalException.cpp:33
ParseError
Parse exception.
Definition
ParseError.h:31
SDDSParserException
Definition
SDDSParserException.h:22
unit_tests
Utilities
TestOpalException.cpp
Generated on Mon Jun 1 2026 10:40:53 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8