Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed May 25, 2020
1 parent ab2eebf commit 004b7ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
28 changes: 14 additions & 14 deletions include/iutest_assertion.hpp
Expand Up @@ -344,7 +344,7 @@ class AssertionHelper
}
ScopedTrace::GetInstance().append_message(m_part_result);

if( TestEnv::GetGlobalTestPartResultReporter() != NULL )
if( TestEnv::GetGlobalTestPartResultReporter() != IUTEST_NULLPTR )
{
TestEnv::GetGlobalTestPartResultReporter()->ReportTestPartResult(m_part_result);
}
Expand Down Expand Up @@ -505,7 +505,7 @@ class NullHelper
template<typename T>
static AssertionResult CompareEq(const char* expr, const T* val)
{
if( NULL == val )
if( IUTEST_NULLPTR == val )
{
return AssertionSuccess();
}
Expand All @@ -517,7 +517,7 @@ class NullHelper
template<typename T>
static AssertionResult CompareNe(const char* expr, const T* val)
{
if( NULL != val )
if( IUTEST_NULLPTR != val )
{
return AssertionSuccess();
}
Expand Down Expand Up @@ -715,7 +715,7 @@ class EqHelper<true>
, detail::IsNullLiteralHelper::Object* val1, T2* val2)
{
IUTEST_UNUSED_VAR(val1);
return CmpHelperEQ(expr1, expr2, static_cast<T2*>(NULL), val2);
return CmpHelperEQ(expr1, expr2, static_cast<T2*>(IUTEST_NULLPTR), val2);
}
#else
template<typename T1, typename T2>
Expand Down Expand Up @@ -820,7 +820,7 @@ class NeHelper<true>
, detail::IsNullLiteralHelper::Object* val1, T2* val2)
{
IUTEST_UNUSED_VAR(val1);
return CmpHelperNE(expr1, expr2, static_cast<T2*>(NULL), val2);
return CmpHelperNE(expr1, expr2, static_cast<T2*>(IUTEST_NULLPTR), val2);
}
#else
template<typename T1, typename T2>
Expand Down Expand Up @@ -849,7 +849,7 @@ class EqHelper
template<typename T>
static AssertionResult Compare(const char* expr1, const char* expr2, ::std::nullptr_t, T* val2)
{
return CmpHelperEQ(expr1, expr2, static_cast<T*>(NULL), val2);
return CmpHelperEQ(expr1, expr2, static_cast<T*>(IUTEST_NULLPTR), val2);
}
};

Expand All @@ -867,7 +867,7 @@ class NeHelper
template<typename T>
static AssertionResult Compare(const char* expr1, const char* expr2, ::std::nullptr_t, T* val2)
{
return CmpHelperNE(expr1, expr2, static_cast<T*>(NULL), val2);
return CmpHelperNE(expr1, expr2, static_cast<T*>(IUTEST_NULLPTR), val2);
}
};

Expand Down Expand Up @@ -942,7 +942,7 @@ namespace StrEqHelper
#if IUTEST_HAS_NULLPTR && 0
#define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T) \
inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(::std::nullptr_t, const T* val2) { \
return val2 == NULL; \
return val2 == IUTEST_NULLPTR; \
}
#else
#define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T)
Expand All @@ -954,7 +954,7 @@ namespace StrEqHelper
return val1 == val2; \
} \
inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T* val1, const T* val2) { \
if( val1 == NULL || val2 == NULL ) { return val1 == val2; } \
if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR ) { return val1 == val2; } \
return Compare(detail::iu_nullable_basic_string_view<T>(val1) \
, detail::iu_nullable_basic_string_view<T>(val2)); \
}
Expand Down Expand Up @@ -1004,7 +1004,7 @@ inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTREQ(
}

return EqFailure(expr1, expr2
, detail::ShowStringQuoted(FormatForComparisonFailureMessage(IUTEST_NULLPTR, val2))
, detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val2))
, detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, IUTEST_NULLPTR)));
}

Expand Down Expand Up @@ -1048,7 +1048,7 @@ inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE(

return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2
<< "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, IUTEST_NULLPTR))
<< " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(IUTEST_NULLPTR, val2));
<< " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val2));
}

template<typename T>
Expand All @@ -1062,7 +1062,7 @@ inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE(
}

return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2
<< "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(IUTEST_NULLPTR, val1))
<< "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val1))
<< " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val1, IUTEST_NULLPTR));
}

Expand All @@ -1071,7 +1071,7 @@ namespace StrCaseEqHelper

inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2)
{
if( val1 == NULL || val2 == NULL )
if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR )
{
return val1 == val2;
}
Expand All @@ -1080,7 +1080,7 @@ inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2)

inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* val1, const wchar_t* val2)
{
if( val1 == NULL || val2 == NULL )
if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR )
{
return val1 == val2;
}
Expand Down
6 changes: 3 additions & 3 deletions include/iutest_printers.hpp
Expand Up @@ -37,7 +37,7 @@ inline void PrintBytesInObjectTo(const unsigned char* buf, size_t size, iu_ostre
IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN()
const size_t kMaxCount = detail::kValues::MaxPrintContainerCount;
*os << size << "-Byte object < ";
if( buf != NULL && size > 0 )
if( buf != IUTEST_NULLPTR && size > 0 )
{
for( size_t i=0; i < size; ++i )
{
Expand Down Expand Up @@ -232,7 +232,7 @@ inline void DefaultPrintTo(IsContainerHelper::no_t
, iutest_type_traits::true_type
, T* ptr, iu_ostream* os)
{
if( ptr == NULL )
if( ptr == IUTEST_NULLPTR )
{
*os << kStrings::Null;
}
Expand All @@ -252,7 +252,7 @@ inline void IUTEST_ATTRIBUTE_UNUSED_ UniversalTersePrint(const T& value, iu_ostr

inline void IUTEST_ATTRIBUTE_UNUSED_ UniversalTersePrint(const char* str, iu_ostream* os)
{
if( str == NULL )
if( str == IUTEST_NULLPTR )
{
*os << kStrings::Null;
}
Expand Down
14 changes: 10 additions & 4 deletions test/spi_tests_decl.cpp
Expand Up @@ -19,6 +19,12 @@

#ifndef FLAVOR
# error FLAVOR
#endif

#if !defined(IUTEST_USE_GTEST)
# define EXPECT_NULL_STR "(null)"
#else
# define EXPECT_NULL_STR ""
#endif

FAILURE_MACRO( FLAVOR(_TRUE)(false), "" );
Expand Down Expand Up @@ -55,15 +61,15 @@
FAILURE_MACRO( FLAVOR(_STREQ)("A", "a"), "" );
FAILURE_MACRO( FLAVOR(_STREQ)("A", null_str), "" );
FAILURE_MACRO( FLAVOR(_STREQ)(null_str, "a"), "" );
FAILURE_MACRO( FLAVOR(_STREQ)(NULL, "a"), "" );
FAILURE_MACRO( FLAVOR(_STREQ)(NULL, "a"), EXPECT_NULL_STR );
FAILURE_MACRO( FLAVOR(_STREQ)(sa, "A"), "" );
FAILURE_MACRO( FLAVOR(_STREQ)("A", sa), "" );
FAILURE_MACRO( FLAVOR(_STREQ)(sa, sb), "" );
FAILURE_MACRO( FLAVOR(_STREQ)(L"A", L"a"), "" );
FAILURE_MACRO( FLAVOR(_STRNE)("a", "a"), "" );
FAILURE_MACRO( FLAVOR(_STRNE)(NULL, null_str), "" );
FAILURE_MACRO( FLAVOR(_STRNE)(null_str, NULL), "" );
FAILURE_MACRO( FLAVOR(_STRNE)(null_str, null_str), "" );
FAILURE_MACRO( FLAVOR(_STRNE)(NULL, null_str), EXPECT_NULL_STR );
FAILURE_MACRO( FLAVOR(_STRNE)(null_str, NULL), EXPECT_NULL_STR );
FAILURE_MACRO( FLAVOR(_STRNE)(null_str, null_str), EXPECT_NULL_STR );
FAILURE_MACRO( FLAVOR(_STRNE)(sa, "a"), "" );
FAILURE_MACRO( FLAVOR(_STRNE)("a", sa), "" );
FAILURE_MACRO( FLAVOR(_STRNE)(sa, sa), "" );
Expand Down

0 comments on commit 004b7ef

Please sign in to comment.