ATLAS Offline Software
Classes | Namespaces | Macros | Functions
Control/AthToolSupport/AsgTesting/AsgTesting/UnitTest.h File Reference
#include <AsgMessaging/MessageCheck.h>
#include <AsgMessaging/MessagePrinterErrorCollect.h>
#include <AsgMessaging/MessagePrinterOverlay.h>
#include <string>
#include <exception>
#include <gtest/gtest.h>
Include dependency graph for Control/AthToolSupport/AsgTesting/AsgTesting/UnitTest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  asg::CheckHelper< T >
 this is an internal traits class for status codes used by the ANA_CHECK* macros More...
 

Namespaces

 asg
 
 asg::detail
 

Macros

#define ASSERT_SUCCESS(x)   ASSERT_EQ (asg::CheckHelper<decltype(x)>::successCode(), x)
 
#define EXPECT_SUCCESS(x)   EXPECT_EQ (asg::CheckHelper<decltype(x)>::successCode(), x)
 
#define ASSERT_FAILURE(x)   ASSERT_EQ (asg::CheckHelper<decltype(x)>::failureCode(), x)
 
#define EXPECT_FAILURE(x)   EXPECT_EQ (asg::CheckHelper<decltype(x)>::failureCode(), x)
 
#define ASSERT_FAILURE_REGEX(x, regex)   ASSERT_FAILURE(x)
 
#define EXPECT_FAILURE_REGEX(x, regex)   EXPECT_FAILURE(x)
 
#define ASSERT_THROW_REGEX(x, regex)
 
#define EXPECT_THROW_REGEX(x, regex)
 
#define ASSERT_MATCH_REGEX(reg, str)   ASSERT_PRED2 (::asg::detail::matchesRegex, reg, str)
 
#define EXPECT_MATCH_REGEX(reg, str)   EXPECT_PRED2 (::asg::detail::matchesRegex, reg, str)
 
#define ATLAS_GOOGLE_TEST_MAIN
 

Functions

bool asg::detail::matchesRegex (const std::string &regex, const std::string &str)
 return whether str matches regex More...
 

Macro Definition Documentation

◆ ASSERT_FAILURE

#define ASSERT_FAILURE (   x)    ASSERT_EQ (asg::CheckHelper<decltype(x)>::failureCode(), x)

◆ ASSERT_FAILURE_REGEX

#define ASSERT_FAILURE_REGEX (   x,
  regex 
)    ASSERT_FAILURE(x)

◆ ASSERT_MATCH_REGEX

#define ASSERT_MATCH_REGEX (   reg,
  str 
)    ASSERT_PRED2 (::asg::detail::matchesRegex, reg, str)

◆ ASSERT_SUCCESS

#define ASSERT_SUCCESS (   x)    ASSERT_EQ (asg::CheckHelper<decltype(x)>::successCode(), x)

◆ ASSERT_THROW_REGEX

#define ASSERT_THROW_REGEX (   x,
  regex 
)
Value:
{ std::string internalTestMessage; try { \
x; internalTestMessage = std::string ("expected statement ") + #x " to throw, but it didn't"; \
} catch (std::exception& e) { \
if (!::asg::detail::matchesRegex ((regex), e.what())) { \
internalTestMessage = std::string ("expected statement ") + #x " to throw message matching " + (regex) + ", but actual message didn't match: " + e.what(); \
} } catch (...) { \
internalTestMessage = std::string ("statement ") + #x " threw an exception that didn't derive from std::exception"; } \
if (!internalTestMessage.empty()) \
FAIL() << internalTestMessage; \
else SUCCEED(); }

Definition at line 83 of file Control/AthToolSupport/AsgTesting/AsgTesting/UnitTest.h.

◆ ATLAS_GOOGLE_TEST_MAIN

#define ATLAS_GOOGLE_TEST_MAIN
Value:
int main (int argc, char **argv) \
{ \
::testing::InitGoogleTest (&argc, argv); \
return RUN_ALL_TESTS(); \
}

Definition at line 117 of file Control/AthToolSupport/AsgTesting/AsgTesting/UnitTest.h.

◆ EXPECT_FAILURE

#define EXPECT_FAILURE (   x)    EXPECT_EQ (asg::CheckHelper<decltype(x)>::failureCode(), x)

◆ EXPECT_FAILURE_REGEX

#define EXPECT_FAILURE_REGEX (   x,
  regex 
)    EXPECT_FAILURE(x)

◆ EXPECT_MATCH_REGEX

#define EXPECT_MATCH_REGEX (   reg,
  str 
)    EXPECT_PRED2 (::asg::detail::matchesRegex, reg, str)

◆ EXPECT_SUCCESS

#define EXPECT_SUCCESS (   x)    EXPECT_EQ (asg::CheckHelper<decltype(x)>::successCode(), x)

◆ EXPECT_THROW_REGEX

#define EXPECT_THROW_REGEX (   x,
  regex 
)
Value:
{ std::string internalTestMessage; try { \
x; internalTestMessage = std::string ("expected statement ") + #x " to throw, but it didn't"; \
} catch (std::exception& e) { \
if (!::asg::detail::matchesRegex ((regex), e.what())) { \
internalTestMessage = std::string ("expected statement ") + #x " to throw message matching " + (regex) + ", but actual message didn't match: " + e.what(); \
} } catch (...) { \
internalTestMessage = std::string ("statement ") + #x " threw an exception that didn't derive from std::exception"; } \
if (!internalTestMessage.empty()) \
ADD_FAILURE() << internalTestMessage; \
else SUCCEED(); }

Definition at line 95 of file Control/AthToolSupport/AsgTesting/AsgTesting/UnitTest.h.

LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
x
#define x
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
asg::detail::matchesRegex
bool matchesRegex(const std::string &regex, const std::string &str)
return whether str matches regex
Definition: Control/AthToolSupport/AsgTesting/Root/UnitTest.cxx:25
calibdata.exception
exception
Definition: calibdata.py:496
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26