Skip to content

Commit

Permalink
add strict warning options (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Jun 3, 2019
1 parent e544bb9 commit f91f522
Show file tree
Hide file tree
Showing 41 changed files with 378 additions and 207 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ for:
cmd: |
cd test
g++ --version; clang++ --version; python --version
@echo. > foo.h && g++ -std=c++1z -dM -E -x c++ foo.h
make showcxxmacros
uname
make -j4
test_script:
Expand All @@ -154,7 +154,7 @@ for:
cmd: |
cd test
g++ --version
@echo. > foo.h && g++ -std=c++1z -dM -E -x c++ foo.h
mingw32-make showcxxmacros
mingw32-make -j4 %MAKE_OPTIONS%
test_script:
cmd: mingw32-make test %MAKE_OPTIONS%
Expand Down
17 changes: 9 additions & 8 deletions include/gtest/iutest_switch_for_gtest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ namespace tr1
#include "iutest_gmock_ver.hpp"
#endif
#include "iutest_gtest_ver.hpp"
#include "../internal/iutest_pragma.hpp"
#include "../internal/iutest_compatible_defs.hpp"

#if GTEST_VER < 0x01040000
# error google test 1.3.0 or less is not supported...
Expand Down Expand Up @@ -182,23 +180,26 @@ namespace tr1

#define IUTEST_HAS_STREAM_BUFFER 0

#define IUTEST_HAS_VARIADIC_TEMPLATES 0
#define IUTEST_HAS_VARIADIC_TEMPLATE_TEMPLATES 0
#define IUTEST_HAS_INITIALIZER_LIST 0
#define IUTEST_HAS_CHAR16_T 0
#define IUTEST_HAS_CHAR32_T 0

#define IUTEST_HAS_EXCEPTIONS GTEST_HAS_EXCEPTIONS
#define IUTEST_HAS_RTTI GTEST_HAS_RTTI
#define IUTEST_HAS_REGEX GTEST_USES_POSIX_RE
#define IUTEST_HAS_SEH GTEST_HAS_SEH
#define IUTEST_HAS_LONG_DOUBLE 0

#if GTEST_VER < 0x01070000
# define IUTEST_NO_RECORDPROPERTY_OUTSIDE_TESTMETHOD_LIFESPAN
# define IUTEST_NO_UNITEST_AD_HOC_TEST_RESULT_ACCESSOR
# define IUTEST_NO_TESTCASE_AD_HOC_TEST_RESULT_ACCESSOR
#endif

#ifndef IUTEST_CXX_OVERRIDE
# define IUTEST_CXX_OVERRIDE
#endif
#ifndef IUTEST_CXX_DEFAULT_FUNCTION
# define IUTEST_CXX_DEFAULT_FUNCTION {}
#endif
#include "../internal/iutest_compiler.hpp"
#include "../internal/iutest_compatible_defs.hpp"

#include "switch/iutest_switch_port.hpp"
#include "switch/iutest_switch_core.hpp"
Expand Down
6 changes: 3 additions & 3 deletions include/gtest/iutest_switch_for_iutest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2018, Takazumi Shirayanagi\n
* Copyright (C) 2011-2019, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -110,11 +110,11 @@ inline void IUTEST_ATTRIBUTE_UNUSED_ InitGoogleTest(int* argc, wchar_t** argv)
#if defined(GMOCK_INCLUDE_GMOCK_GMOCK_H_)
inline void IUTEST_ATTRIBUTE_UNUSED_ InitGoogleMock(int* argc, char** argv)
{
testing::InitGoogleMock(argc, argv);
::testing::InitGoogleMock(argc, argv);
}
inline void IUTEST_ATTRIBUTE_UNUSED_ InitGoogleMock(int* argc, wchar_t** argv)
{
testing::InitGoogleMock(argc, argv);
::testing::InitGoogleMock(argc, argv);
}
#endif

Expand Down
6 changes: 4 additions & 2 deletions include/gtest/switch/iutest_switch_assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@
#define IUTEST_ASSERT_GT ASSERT_GT
#define IUTEST_ASSERT_GE ASSERT_GE
#define IUTEST_ASSERT_NEAR ASSERT_NEAR
#define IUTEST_ASSERT_NULL(...) IUTEST_THROUGH_ANALYSIS_ASSUME((__VA_ARGS__) == NULL, ASSERT_EQ(NULL, (__VA_ARGS__)))
#define IUTEST_ASSERT_NOTNULL(...) IUTEST_THROUGH_ANALYSIS_ASSUME((__VA_ARGS__) != NULL, ASSERT_TRUE(NULL != (__VA_ARGS__)))
#define IUTEST_ASSERT_NULL(...) IUTEST_THROUGH_ANALYSIS_ASSUME((__VA_ARGS__) == IUTEST_NULLPTR \
, ASSERT_EQ(IUTEST_NULLPTR, (__VA_ARGS__)))
#define IUTEST_ASSERT_NOTNULL(...) IUTEST_THROUGH_ANALYSIS_ASSUME((__VA_ARGS__) != IUTEST_NULLPTR \
, ASSERT_TRUE(IUTEST_NULLPTR != (__VA_ARGS__)))
#define IUTEST_ASSERT_SAME(v1, v2) ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSame, v1, v2)
#define IUTEST_ASSERT_FLOAT_EQ ASSERT_FLOAT_EQ
#define IUTEST_ASSERT_DOUBLE_EQ ASSERT_DOUBLE_EQ
Expand Down
4 changes: 2 additions & 2 deletions include/gtest/switch/iutest_switch_assume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
#define IUTEST_ASSUME_LE ASSUME_LE
#define IUTEST_ASSUME_GT ASSUME_GT
#define IUTEST_ASSUME_GE ASSUME_GE
#define IUTEST_ASSUME_NULL(...) ASSUME_EQ(NULL, (__VA_ARGS__))
#define IUTEST_ASSUME_NOTNULL(...) ASSUME_TRUE(NULL != (__VA_ARGS__))
#define IUTEST_ASSUME_NULL(...) ASSUME_EQ(IUTEST_NULLPTR, (__VA_ARGS__))
#define IUTEST_ASSUME_NOTNULL(...) ASSUME_TRUE(IUTEST_NULLPTR != (__VA_ARGS__))
#define IUTEST_ASSUME_SAME(v1, v2) ASSUME_PRED_FORMAT2(::testing::internal::CmpHelperSame, v1, v2)
#define IUTEST_ASSUME_NEAR ASSUME_NEAR
#define IUTEST_ASSUME_FLOAT_EQ ASSUME_FLOAT_EQ
Expand Down
3 changes: 0 additions & 3 deletions include/gtest/switch/iutest_switch_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#define REGISTER_TYPED_TEST_CASE_P IUTEST_REGISTER_TYPED_TEST_CASE_P
#define INSTANTIATE_TYPED_TEST_CASE_P IUTEST_INSTANTIATE_TYPED_TEST_CASE_P

#define GTEST_ATTRIBUTE_UNUSED_ IUTEST_ATTRIBUTE_UNUSED_
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ IUTEST_AMBIGUOUS_ELSE_BLOCKER_

#define GTEST_TEST_CLASS_NAME_ IUTEST_TEST_CLASS_NAME_
Expand Down Expand Up @@ -115,7 +114,6 @@
#endif


#undef IUTEST_ATTRIBUTE_UNUSED_
#undef IUTEST_AMBIGUOUS_ELSE_BLOCKER_

#undef IUTEST_TEST_CLASS_NAME_
Expand Down Expand Up @@ -166,7 +164,6 @@
#define IUTEST_REGISTER_TYPED_TEST_CASE_P REGISTER_TYPED_TEST_CASE_P
#define IUTEST_INSTANTIATE_TYPED_TEST_CASE_P INSTANTIATE_TYPED_TEST_CASE_P

#define IUTEST_ATTRIBUTE_UNUSED_ GTEST_ATTRIBUTE_UNUSED_
#define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ GTEST_AMBIGUOUS_ELSE_BLOCKER_

#define IUTEST_TEST_CLASS_NAME_ GTEST_TEST_CLASS_NAME_
Expand Down
4 changes: 2 additions & 2 deletions include/gtest/switch/iutest_switch_expect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
#define IUTEST_EXPECT_GT EXPECT_GT
#define IUTEST_EXPECT_GE EXPECT_GE
#define IUTEST_EXPECT_NEAR EXPECT_NEAR
#define IUTEST_EXPECT_NULL(...) EXPECT_EQ(NULL, (__VA_ARGS__))
#define IUTEST_EXPECT_NOTNULL(...) EXPECT_TRUE(NULL != (__VA_ARGS__))
#define IUTEST_EXPECT_NULL(...) EXPECT_EQ(IUTEST_NULLPTR, (__VA_ARGS__))
#define IUTEST_EXPECT_NOTNULL(...) EXPECT_TRUE(IUTEST_NULLPTR != (__VA_ARGS__))
#define IUTEST_EXPECT_SAME(v1, v2) EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSame, v1, v2)
#define IUTEST_EXPECT_FLOAT_EQ EXPECT_FLOAT_EQ
#define IUTEST_EXPECT_DOUBLE_EQ EXPECT_DOUBLE_EQ
Expand Down
4 changes: 2 additions & 2 deletions include/gtest/switch/iutest_switch_inform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@
#define IUTEST_INFORM_LE INFORM_LE
#define IUTEST_INFORM_GT INFORM_GT
#define IUTEST_INFORM_GE INFORM_GE
#define IUTEST_INFORM_NULL(...) INFORM_EQ(NULL, (__VA_ARGS__))
#define IUTEST_INFORM_NOTNULL(...) INFORM_TRUE(NULL != (__VA_ARGS__))
#define IUTEST_INFORM_NULL(...) INFORM_EQ(IUTEST_NULLPTR, (__VA_ARGS__))
#define IUTEST_INFORM_NOTNULL(...) INFORM_TRUE(IUTEST_NULLPTR != (__VA_ARGS__))
#define IUTEST_INFORM_SAME(v1, v2) INFORM_PRED_FORMAT2(::testing::internal::CmpHelperSame, v1, v2)
#define IUTEST_INFORM_NEAR INFORM_NEAR
#define IUTEST_INFORM_FLOAT_EQ INFORM_FLOAT_EQ
Expand Down
8 changes: 5 additions & 3 deletions include/gtest/switch/iutest_switch_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
# undef IUTEST_OS_NACL
#endif

#define GTEST_ATTRIBUTE_UNUSED_ IUTEST_ATTRIBUTE_UNUSED_

#endif

//======================================================================
Expand Down Expand Up @@ -112,8 +114,6 @@

//======================================================================
// undef
#if defined(INCG_IRIS_IUTEST_HPP_)

#ifdef IUTEST_OS_CYGWIN
# undef IUTEST_OS_CYGWIN
#endif
Expand Down Expand Up @@ -157,7 +157,7 @@
# undef IUTEST_OS_NACL
#endif

#endif
#undef IUTEST_ATTRIBUTE_UNUSED_

//======================================================================
// define
Expand Down Expand Up @@ -211,6 +211,8 @@
# define IUTEST_OS_NACL GTEST_OS_NACL
#endif

#define IUTEST_ATTRIBUTE_UNUSED_ GTEST_ATTRIBUTE_UNUSED_

IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()

//======================================================================
Expand Down
7 changes: 5 additions & 2 deletions include/impl/iutest_charcode.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2017, Takazumi Shirayanagi\n
* Copyright (C) 2011-2019, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -102,7 +102,7 @@ IUTEST_IPP_INLINE char* CodePointToUtf8(UInt32 code_point, char* buf, size_t siz
}
else
{
iu_snprintf(buf, size, "(Invalid UTF16 0x%X)", code_point);
iu_snprintf(buf, size, "(Invalid UTF16 0x%s)", ToHexString(code_point).c_str());
}
return buf;
}
Expand Down Expand Up @@ -231,7 +231,10 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()
IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
return ret;
#else
IUTEST_PRAGMA_WARN_PUSH()
IUTEST_PRAGMA_WARN_CAST_ALIGN()
return WideStringToUTF8(reinterpret_cast<const wchar_t*>(str), num);
IUTEST_PRAGMA_WARN_POP()
#endif
}

Expand Down
18 changes: 6 additions & 12 deletions include/impl/iutest_core_impl.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,29 @@ IUTEST_IPP_INLINE void UnitTestImpl::SkipTest()

IUTEST_IPP_INLINE int UnitTestImpl::Listup() const
{
detail::iuConsole::output("%d tests from %d testcase\n", m_total_test_num, m_testcases.size() );
detail::iuConsole::output("%d tests from %" IUPRzu " testcase\n", m_total_test_num, m_testcases.size() );
for( iuTestCases::const_iterator it = m_testcases.begin(), end=m_testcases.end(); it != end; ++it )
{
detail::iuConsole::output((*it)->name());
detail::iuConsole::output("\n");
detail::iuConsole::output("%s\n", (*it)->name());

for( TestCase::iuTestInfos::const_iterator it2 = (*it)->begin(), end2=(*it)->end(); it2 != end2; ++it2 )
{
detail::iuConsole::output(" ");
detail::iuConsole::output((*it2)->name());
detail::iuConsole::output("\n");
detail::iuConsole::output(" %s\n", (*it2)->name());
}
}
return 0;
}

IUTEST_IPP_INLINE int UnitTestImpl::ListupWithWhere() const
{
detail::iuConsole::output("%d tests from %d testcase\n", m_total_test_num, m_testcases.size() );
detail::iuConsole::output("%d tests from %" IUPRzu " testcase\n", m_total_test_num, m_testcases.size() );
for( iuTestCases::const_iterator it = m_testcases.begin(), end=m_testcases.end(); it != end; ++it )
{
detail::iuConsole::output((*it)->testcase_name_with_where().c_str());
detail::iuConsole::output("\n");
detail::iuConsole::output("%s\n", (*it)->testcase_name_with_where().c_str());

for( TestCase::iuTestInfos::const_iterator it2 = (*it)->begin(), end2=(*it)->end(); it2 != end2; ++it2 )
{
detail::iuConsole::output(" ");
detail::iuConsole::output((*it2)->test_name_with_where().c_str());
detail::iuConsole::output("\n");
detail::iuConsole::output(" %s\n", (*it2)->test_name_with_where().c_str());
}
}
return 0;
Expand Down
13 changes: 7 additions & 6 deletions include/impl/iutest_default_printer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2018, Takazumi Shirayanagi\n
* Copyright (C) 2011-2019, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -70,10 +70,11 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestStart(const TestInfo& t
IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestPartResult(const TestPartResult& test_part_result)
{
//if( test_part_result.type() == TestPartResult::kSuccess ) return;
const std::string msg = test_part_result.make_newline_message();;
#if defined(_MSC_VER) && !defined(IUTEST_OS_WINDOWS_MOBILE)
OutputDebugStringA(test_part_result.make_newline_message().c_str());
OutputDebugStringA(msg.c_str());
#endif
detail::iuConsole::output(test_part_result.make_newline_message().c_str());
detail::iuConsole::output("%s", msg.c_str());
}
IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestRecordProperty(const TestProperty& test_property)
{
Expand Down Expand Up @@ -104,7 +105,7 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestEnd(const TestInfo& tes
#if defined(IUTEST_NOT_SUPPORT_STOPWATCH)
detail::iuConsole::output(" (--ms)" );
#else
detail::iuConsole::output(" (%dms)", test_info.elapsed_time());
detail::iuConsole::output(" (%sms)", detail::FormatTimeInMillisec(test_info.elapsed_time()).c_str());
#endif
}
detail::iuConsole::output("\n");
Expand All @@ -118,7 +119,7 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestCaseEnd(const TestCase&
#if defined(IUTEST_NOT_SUPPORT_STOPWATCH)
detail::iuConsole::output("(--ms total)");
#else
detail::iuConsole::output("(%dms total)", test_case.elapsed_time() );
detail::iuConsole::output("(%sms total)", detail::FormatTimeInMillisec(test_case.elapsed_time()).c_str());
#endif
}
detail::iuConsole::output("\n\n");
Expand Down Expand Up @@ -147,7 +148,7 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestIterationEnd(const Unit
#if defined(IUTEST_NOT_SUPPORT_STOPWATCH)
detail::iuConsole::output(" (--ms total)");
#else
detail::iuConsole::output(" (%dms total)", test.elapsed_time() );
detail::iuConsole::output(" (%sms total)", detail::FormatTimeInMillisec(test.elapsed_time()).c_str());
#endif
}
detail::iuConsole::output("\n");
Expand Down
6 changes: 5 additions & 1 deletion include/impl/iutest_default_xml_generator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2018, Takazumi Shirayanagi\n
* Copyright (C) 2011-2019, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -32,11 +32,15 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnTestIterationStart(const U
}
if( !m_output_path_format.empty() )
{
// FIXME: -Wformat-nonliteral
IUTEST_PRAGMA_WARN_PUSH()
IUTEST_PRAGMA_WARN_FORMAT_NONLITERAL()
m_output_path = detail::StringFormat(m_output_path_format.c_str(), iteration);
if( m_output_path == m_output_path_format)
{
m_output_path_format.clear();
}
IUTEST_PRAGMA_WARN_POP()
if( m_fp != NULL )
{
OnReportTest(m_fp, test);
Expand Down
7 changes: 7 additions & 0 deletions include/impl/iutest_time.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ IUTEST_IPP_INLINE bool Localtime(time_t sec, struct tm* dst)
#endif
}

IUTEST_IPP_INLINE ::std::string FormatTimeInMillisec(TimeInMillisec msec)
{
iu_stringstream ss;
ss << msec;
return ss.str();
}

IUTEST_IPP_INLINE ::std::string FormatTimeInMillisecAsSecond(TimeInMillisec msec)
{
iu_stringstream ss;
Expand Down

0 comments on commit f91f522

Please sign in to comment.