Skip to content

Commit

Permalink
[Tests] Convert all CPPUnitHelper functions to GTest equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloGalav committed Aug 4, 2023
1 parent 0291cee commit eab18cf
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions tests/XrdCl/GTestXrdHelpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

#ifndef __GTEST_XRD_HELPERS_HH__
#define __GTEST_XRD_HELPERS_HH__

#include <gtest/gtest.h>
#include <XrdCl/XrdClXRootDResponses.hh>
#include <cerrno>
Expand All @@ -26,8 +29,42 @@
* Shows the code that we are asserting and its value
* in the final evaluation.
*/
#define GTEST_ASSERT_XRDST( x ) \
{ \
XrdCl::XRootDStatus _st = x; \
EXPECT_TRUE(_st.IsOK()) << "[" << #x << "]: " << _st.ToStr() << std::endl; \
#define GTEST_ASSERT_XRDST( x ) \
{ \
XrdCl::XRootDStatus _st = x; \
EXPECT_TRUE(_st.IsOK()) << "[" << #x << "]: " << _st.ToStr() << std::endl; \
}

/** @brief Equivalent of CPPUNIT_ASSERT_XRDST_NOTOK
*
* Shows the code that we are asserting and asserts that its
* execution is throwing an error.
*/
#define GTEST_ASSERT_XRDST_NOTOK( x, err ) \
{ \
XrdCl::XRootDStatus _st = x; \
EXPECT_TRUE(!_st.IsOK() && _st.code == err) << "[" << #x << "]: " << _st.ToStr() << std::endl; \
}

/** @brief Equivalent of CPPUNIT_ASSERT_ERRNO
*
* Shows the code that we are asserting and its error
* number.
*/
#define GTEST_ASSERT_ERRNO( x ) \
{ \
EXPECT_TRUE(x) << "[" << #x << "]: " << strerror(errno) << std::endl; \
}

/** @brief Equivalent of GTEST_ASSERT_PTHREAD
*
* Shows the code that we are asserting and its error
* number, in a thread-safe manner.
*/
#define GTEST_ASSERT_PTHREAD( x ) \
{ \
errno = x; \
EXPECT_TRUE(errno == 0) << "[" << #x << "]: " << strerror(errno) << std::endl; \
}

#endif // __GTEST_XRD_HELPERS_HH__

0 comments on commit eab18cf

Please sign in to comment.