Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
c1df754f
Commit
c1df754f
authored
Sep 23, 2015
by
Francis Dupont
Browse files
[master] Merged trac4032 (improve unit tests for exceptions)
parents
45a70053
0d1006f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/exceptions/tests/exceptions_unittest.cc
View file @
c1df754f
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2009
, 2015
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -30,6 +30,10 @@ protected:
const
char
*
teststring
;
};
void
raise_foobar
()
{
isc_throw
(
isc
::
BadValue
,
"foobar"
);
}
TEST_F
(
ExceptionTest
,
basicMethods
)
{
try
{
isc_throw
(
Exception
,
teststring
);
...
...
@@ -68,4 +72,22 @@ TEST_F(ExceptionTest, verbose) {
}
}
// A full example of how to check both the exception (e.g., EXPECT_THROW)
// and its associated message (something no gtest macros do).
TEST_F
(
ExceptionTest
,
message
)
{
try
{
raise_foobar
();
ADD_FAILURE
()
<<
"Expected "
"raise_foobar()"
\
" throws an exception of type "
"BadValue"
\
".
\n
Actual: it throws nothing."
;
}
catch
(
const
isc
::
BadValue
&
ex
)
{
EXPECT_EQ
(
std
::
string
(
ex
.
getMessage
()),
"foobar"
);
}
catch
(...)
{
ADD_FAILURE
()
<<
"Expected "
"raise_foobar()"
\
" throws an exception of type "
"BadValue"
\
".
\n
Actual: it throws a different type."
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment