From d32751020a0c472d7b6a576955f69195f43b6a3e Mon Sep 17 00:00:00 2001 From: srz-zumix Date: Wed, 7 Jan 2015 08:18:08 +0900 Subject: [PATCH] update r770 --- doc/Doxyfile | 2 +- include/impl/iutest_port.ipp | 23 ++++++++++++++++++++--- include/internal/iutest_compiler.hpp | 14 ++++++++++---- include/iutest_assertion.hpp | 27 ++++++++++++++++----------- include/iutest_ver.hpp | 4 ++-- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index 565972c054..139417e3ae 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = iutest # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.11.0.1 +PROJECT_NUMBER = 1.11.0.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/include/impl/iutest_port.ipp b/include/impl/iutest_port.ipp index 4623853b66..acb44f867c 100644 --- a/include/impl/iutest_port.ipp +++ b/include/impl/iutest_port.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2014, Takazumi Shirayanagi\n + * Copyright (C) 2011-2015, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -115,13 +115,30 @@ IUTEST_IPP_INLINE const char* GetCWD(char* buf, size_t length) #elif defined(IUTEST_OS_WINDOWS) return ::GetCurrentDirectoryA(static_cast(length), buf) == 0 ? NULL : buf; #else - return getcwd(buf, length); + const char* result = getcwd(buf, length); + if( result == NULL && buf != NULL && length >= 1 ) + { +#if defined(IUTEST_OS_NACL) + if( length < 3 ) + { + return NULL; + } + buf[0] = '.'; + buf[1] = '/'; + buf[2] = '\0'; + return buf; +#else + buf[0] = '\0'; + return buf; +#endif + } + return result; #endif } IUTEST_IPP_INLINE ::std::string GetCWD(void) { - char buf[260]; + char buf[260] = { 0 }; return GetCWD(buf, sizeof(buf)); } diff --git a/include/internal/iutest_compiler.hpp b/include/internal/iutest_compiler.hpp index c1f35d6127..569005c52f 100644 --- a/include/internal/iutest_compiler.hpp +++ b/include/internal/iutest_compiler.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2014, Takazumi Shirayanagi\n + * Copyright (C) 2011-2015, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -929,13 +929,19 @@ //! unused attribute #if !defined(IUTEST_ATTRIBUTE_UNUSED_) -# if (defined(__GNUC__) && !defined(COMPILER_ICC)) || defined(__clang__) +# if (defined(__GNUC__) && !defined(COMPILER_ICC)) # define IUTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) -# else -# define IUTEST_ATTRIBUTE_UNUSED_ +# elif defined(__clang__) +# if __has_attribute(unused)) +# define IUTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +# endif # endif #endif +#if !defined(IUTEST_ATTRIBUTE_UNUSED_) +# define IUTEST_ATTRIBUTE_UNUSED_ +#endif + //! pure attribute #if !defined(IUTEST_ATTRIBUTE_PURE_) # if defined(__GNUC__) && !defined(COMPILER_ICC) diff --git a/include/iutest_assertion.hpp b/include/iutest_assertion.hpp index 0711423fb5..b128beac86 100644 --- a/include/iutest_assertion.hpp +++ b/include/iutest_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2014, Takazumi Shirayanagi\n + * Copyright (C) 2011-2015, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -414,19 +414,24 @@ inline AssertionResult EqFailure(const char* expected_expression, const char* ac return AssertionFailure() << strm.str(); } +template +inline AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, const char* op + , const T1& val1, const T2& val2) +{ + return AssertionFailure() << "error: Expected: " << expr1 << " " << op << " " << expr2 + << "\n Actual: " << FormatForComparisonFailureMessage(val1, val2) + << " vs " << FormatForComparisonFailureMessage(val2, val1); +} + /** * @private * @{ -*/ -#define DECL_COMPARE_HELPER_I_(op_name, op, type1, type2) \ - inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelper##op_name( \ - const char* expr1, const char* expr2, type1 val1, type2 val2) { \ - if( val1 op val2 ) { return AssertionSuccess(); \ - } else { \ - return AssertionFailure() << "error: Expected: " << expr1 << " " #op " " << expr2 \ - << "\n Actual: " << FormatForComparisonFailureMessage(val1, val2) \ - << " vs " << FormatForComparisonFailureMessage(val2, val1); \ - } \ + */ +#define DECL_COMPARE_HELPER_I_(op_name, op, type1, type2) \ + inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelper##op_name( \ + const char* expr1, const char* expr2, type1 val1, type2 val2) { \ + if( val1 op val2 ) { return AssertionSuccess(); \ + } else { return CmpHelperOpFailure(expr1, expr2, #op, val1, val2); } \ } #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING) diff --git a/include/iutest_ver.hpp b/include/iutest_ver.hpp index 26ce9b44cc..10d291f0aa 100644 --- a/include/iutest_ver.hpp +++ b/include/iutest_ver.hpp @@ -17,11 +17,11 @@ //====================================================================== // define -#define IUTEST_VER 0x01110001u //!< iutest version 1.11.0.1 +#define IUTEST_VER 0x01110002u //!< iutest version 1.11.0.2 #define IUTEST_MAJORVER 0x01u //!< Major Version #define IUTEST_MINORVER 0x11u //!< Minor Version #define IUTEST_BUILD 0x00u //!< Build -#define IUTEST_REVISION 0x01u //!< Revision +#define IUTEST_REVISION 0x02u //!< Revision /** * @mainpage