Kea  1.9.9-git
gtest_utils.h File Reference
#include <gtest/gtest.h>
+ Include dependency graph for gtest_utils.h:

Go to the source code of this file.

Namespaces

 isc
 Defines the logger used by the top-level component of kea-dhcp-ddns.
 
 isc::test
 

Macros

#define ASSERT_NO_THROW_LOG(statement)
 Generates a fatal failure with exception info, if the given expression throws. More...
 
#define ASSERT_THROW_MSG(statement, etype, emsg)
 Verifies an expected exception type and message. More...
 
#define EXPECT_NO_THROW_LOG(statement)
 Adds a non-fatal failure with exception info, if the given expression throws. More...
 
#define EXPECT_THROW_MSG(statement, etype, emsg)
 Verifies an expected exception type and message. More...
 

Macro Definition Documentation

#define ASSERT_NO_THROW_LOG (   statement)
Value:
{ \
try { \
statement; \
} catch (const std::exception& ex) { \
GTEST_FAIL() << #statement << " threw type: " << typeid(ex).name() \
<< ", what: " << ex.what(); \
} catch (...) { \
GTEST_FAIL() << #statement << " threw non-std::exception"; \
} \
} \

Generates a fatal failure with exception info, if the given expression throws.

Note the type name emitted may be mangled.

Parameters
statement- statement block to execute

Definition at line 77 of file gtest_utils.h.

#define ASSERT_THROW_MSG (   statement,
  etype,
  emsg 
)
Value:
{ \
try { \
statement; \
GTEST_FAIL() << "no exception, expected: " << #etype; \
} catch (const etype& ex) { \
ASSERT_EQ(std::string(ex.what()), emsg); \
} catch (...) { \
GTEST_FAIL() << "wrong exception type thrown, expected: " << #etype; \
} \
} \

Verifies an expected exception type and message.

If the statement does not generate the expected exception containing the expected message it will generate a fatal failure.

Parameters
statement- statement block to execute
etype- type of exception expected
emsg- exact content expected to be returned by ex.what()

Definition at line 45 of file gtest_utils.h.

#define EXPECT_NO_THROW_LOG (   statement)
Value:
{ \
try { \
statement; \
} catch (const std::exception& ex) { \
ADD_FAILURE() << #statement << " threw type: " << typeid(ex).name() \
<< ", what: " << ex.what(); \
} catch (...) { \
ADD_FAILURE() << #statement << "threw non-std::exception"; \
} \
} \

Adds a non-fatal failure with exception info, if the given expression throws.

Note the type name emitted may be mangled.

Parameters
statement- statement block to execute

Definition at line 61 of file gtest_utils.h.

#define EXPECT_THROW_MSG (   statement,
  etype,
  emsg 
)
Value:
{ \
try { \
statement; \
ADD_FAILURE() << "no exception, expected: " << #etype; \
} catch (const etype& ex) { \
EXPECT_EQ(std::string(ex.what()), emsg); \
} catch (...) { \
ADD_FAILURE() << "wrong exception type thrown, expected: " << #etype; \
} \
} \

Verifies an expected exception type and message.

If the statement does not generate the expected exception containing the expected message it will generate a non-fatal failure.

Parameters
statement- statement block to execute
etype- type of exception expected
emsg- exact content expected to be returned by ex.what()

Definition at line 24 of file gtest_utils.h.