OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Macros
ExpectExtensions.h File Reference
#include <exception>
#include <string_view>
#include <gtest/gtest.h>

Macros

#define EXPECT_THROW_MESSAGE(STATEMENT, MESSAGE)
 
#define EXPECT_CONTAINS(HAYSTACK, NEEDLE)
 
#define EXPECT_MISSES(HAYSTACK, NEEDLE)
 

Macro Definition Documentation

◆ EXPECT_CONTAINS

#define EXPECT_CONTAINS (   HAYSTACK,
  NEEDLE 
)
Value:
do { \
const auto &__haystack = (HAYSTACK); \
const auto &__needle = (NEEDLE); \
EXPECT_TRUE(__haystack.contains(__needle)) \
<< #HAYSTACK << " (" << testing::PrintToString(__haystack) << ") doesn't contain " \
<< #NEEDLE << " (" << testing::PrintToString(__needle) << ")"; \
} while (0)

◆ EXPECT_MISSES

#define EXPECT_MISSES (   HAYSTACK,
  NEEDLE 
)
Value:
do { \
const auto &__haystack = (HAYSTACK); \
const auto &__needle = (NEEDLE); \
EXPECT_FALSE(__haystack.contains(__needle)) \
<< #HAYSTACK << " (" << testing::PrintToString(__haystack) << ") contains " \
<< #NEEDLE << " (" << testing::PrintToString(__needle) << ")"; \
} while (0)

◆ EXPECT_THROW_MESSAGE

#define EXPECT_THROW_MESSAGE (   STATEMENT,
  MESSAGE 
)
Value:
do { \
try { \
STATEMENT; \
EXPECT_TRUE(false) << #STATEMENT << " didn't throw."; \
} catch (const std::exception &e) { \
EXPECT_CONTAINS(std::string_view(e.what()), (MESSAGE)); \
} catch (...) { \
EXPECT_TRUE(false) << #STATEMENT << " has thrown an unknown exception."; \
} \
} while (0)
TotallyBrokenEnum e
Definition: Json_ut.cpp:135