Skip to content

Commit

Permalink
Tweak preprocessor blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjohnmeyer committed Jan 30, 2016
1 parent f82c403 commit bb7555c
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .uncrustify
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ cmt_insert_func_header = ""
cmt_insert_class_header = ""
cmt_insert_oc_msg_header = ""
cmt_insert_before_preproc = false
pp_indent = remove
pp_indent = ignore
pp_indent_at_level = false
pp_indent_count = 3
pp_space = ignore
Expand Down
14 changes: 8 additions & 6 deletions UnitTest++/CheckMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
#include "ReportAssertImpl.h"

#ifdef CHECK
#error UnitTest++ redefines CHECK
#error UnitTest++ redefines CHECK
#endif

#ifdef CHECK_EQUAL
#error UnitTest++ redefines CHECK_EQUAL
#error UnitTest++ redefines CHECK_EQUAL
#endif

#ifdef CHECK_CLOSE
#error UnitTest++ redefines CHECK_CLOSE
#error UnitTest++ redefines CHECK_CLOSE
#endif

#ifdef CHECK_ARRAY_EQUAL
#error UnitTest++ redefines CHECK_ARRAY_EQUAL
#error UnitTest++ redefines CHECK_ARRAY_EQUAL
#endif

#ifdef CHECK_ARRAY_CLOSE
#error UnitTest++ redefines CHECK_ARRAY_CLOSE
#error UnitTest++ redefines CHECK_ARRAY_CLOSE
#endif

#ifdef CHECK_ARRAY2D_CLOSE
#error UnitTest++ redefines CHECK_ARRAY2D_CLOSE
#error UnitTest++ redefines CHECK_ARRAY2D_CLOSE
#endif

#define CHECK(value) \
Expand Down Expand Up @@ -158,6 +158,7 @@

// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_NO_EXCEPTIONS isn't defined (see config.h)
#ifndef UNITTEST_NO_EXCEPTIONS

#define CHECK_THROW(expression, ExpectedExceptionType) \
UNITTEST_MULTILINE_MACRO_BEGIN \
bool caught_ = false; \
Expand All @@ -176,4 +177,5 @@
UnitTest::Detail::ExpectAssert(false); \
UNITTEST_MULTILINE_MACRO_END
#endif

#endif
37 changes: 19 additions & 18 deletions UnitTest++/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@
// Standard defines documented here: http://predef.sourceforge.net

#if defined(_MSC_VER)
#pragma warning(disable:4702)// unreachable code
#pragma warning(disable:4722)// destructor never returns, potential memory leak

#if (_MSC_VER == 1200) // VC6
#define UNITTEST_COMPILER_IS_MSVC6
#pragma warning(disable:4786)
#pragma warning(disable:4290)
#endif

#ifdef _USRDLL
#define UNITTEST_WIN32_DLL
#endif
#define UNITTEST_WIN32
#pragma warning(disable:4702)// unreachable code
#pragma warning(disable:4722)// destructor never returns, potential memory leak

#if (_MSC_VER == 1200) // VC6
#define UNITTEST_COMPILER_IS_MSVC6
#pragma warning(disable:4786)
#pragma warning(disable:4290)
#endif

#ifdef _USRDLL
#define UNITTEST_WIN32_DLL
#endif

#define UNITTEST_WIN32
#endif

#if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \
defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
#define UNITTEST_POSIX
#define UNITTEST_POSIX
#endif

#if defined(__MINGW32__)
#define UNITTEST_MINGW
#define UNITTEST_MINGW
#endif


Expand All @@ -43,7 +44,7 @@
// well as Google Code HEAD users that may have used or defined
// UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM outside of this configuration file.
#ifndef UNITTEST_USE_CUSTOM_STREAMS
#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
#endif

// DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like
Expand All @@ -65,9 +66,9 @@
// std namespace qualification: used for functions like strcpy that
// may live in std:: namespace (cstring header).
#if defined( UNITTEST_COMPILER_IS_MSVC6 )
#define UNIITEST_NS_QUAL_STD(x) x
#define UNIITEST_NS_QUAL_STD(x) x
#else
#define UNIITEST_NS_QUAL_STD(x) ::std::x
#define UNIITEST_NS_QUAL_STD(x) ::std::x
#endif

#endif
16 changes: 8 additions & 8 deletions UnitTest++/ExceptionMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#include "Config.h"

#ifndef UNITTEST_NO_EXCEPTIONS
#define UT_TRY(x) try x
#define UT_THROW(x) throw x
#define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody
#define UT_CATCH_ALL(CatchBody) catch(...) CatchBody
#define UT_TRY(x) try x
#define UT_THROW(x) throw x
#define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody
#define UT_CATCH_ALL(CatchBody) catch(...) CatchBody
#else
#define UT_TRY(x) x
#define UT_THROW(x)
#define UT_CATCH(ExceptionType, ExceptionName, CatchBody)
#define UT_CATCH_ALL(CatchBody)
#define UT_TRY(x) x
#define UT_THROW(x)
#define UT_CATCH(ExceptionType, ExceptionName, CatchBody)
#define UT_CATCH_ALL(CatchBody)
#endif

#endif
62 changes: 31 additions & 31 deletions UnitTest++/HelperMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,47 @@
#define UNITTEST_MULTILINE_MACRO_BEGIN do {

#if defined(UNITTEST_WIN32) && !defined(UNITTEST_COMPILER_IS_MSVC6)
#define UNITTEST_MULTILINE_MACRO_END \
} __pragma(warning(push)) __pragma(warning(disable: 4127)) while (0) __pragma(warning(pop))
#define UNITTEST_MULTILINE_MACRO_END \
} __pragma(warning(push)) __pragma(warning(disable: 4127)) while (0) __pragma(warning(pop))
#else
#define UNITTEST_MULTILINE_MACRO_END } while(0)
#define UNITTEST_MULTILINE_MACRO_END } while(0)
#endif


#ifdef UNITTEST_WIN32_DLL
#define UNITTEST_IMPORT __declspec(dllimport)
#define UNITTEST_EXPORT __declspec(dllexport)

#ifdef UNITTEST_DLL_EXPORT
#define UNITTEST_LINKAGE UNITTEST_EXPORT
#define UNITTEST_IMPEXP_TEMPLATE
#else
#define UNITTEST_LINKAGE UNITTEST_IMPORT
#define UNITTEST_IMPEXP_TEMPLATE extern
#endif

#define UNITTEST_STDVECTOR_LINKAGE(T) \
__pragma(warning(push)) \
__pragma(warning(disable: 4231)) \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::allocator< T >; \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::vector< T >; \
__pragma(warning(pop))
#define UNITTEST_IMPORT __declspec(dllimport)
#define UNITTEST_EXPORT __declspec(dllexport)

#ifdef UNITTEST_DLL_EXPORT
#define UNITTEST_LINKAGE UNITTEST_EXPORT
#define UNITTEST_IMPEXP_TEMPLATE
#else
#define UNITTEST_LINKAGE UNITTEST_IMPORT
#define UNITTEST_IMPEXP_TEMPLATE extern
#endif

#define UNITTEST_STDVECTOR_LINKAGE(T) \
__pragma(warning(push)) \
__pragma(warning(disable: 4231)) \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::allocator< T >; \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::vector< T >; \
__pragma(warning(pop))
#else
#define UNITTEST_IMPORT
#define UNITTEST_EXPORT
#define UNITTEST_LINKAGE
#define UNITTEST_IMPEXP_TEMPLATE
#define UNITTEST_STDVECTOR_LINKAGE(T)
#define UNITTEST_IMPORT
#define UNITTEST_EXPORT
#define UNITTEST_LINKAGE
#define UNITTEST_IMPEXP_TEMPLATE
#define UNITTEST_STDVECTOR_LINKAGE(T)
#endif

#ifdef UNITTEST_WIN32
#define UNITTEST_JMPBUF jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP longjmp
#define UNITTEST_JMPBUF jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP longjmp
#elif defined UNITTEST_POSIX
#define UNITTEST_JMPBUF std::jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP std::longjmp
#define UNITTEST_JMPBUF std::jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP std::longjmp
#endif

#endif
2 changes: 1 addition & 1 deletion UnitTest++/ReportAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "TestDetails.h"

#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
#include "ReportAssertImpl.h"
#endif

namespace UnitTest {
Expand Down
2 changes: 1 addition & 1 deletion UnitTest++/ReportAssertImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "HelperMacros.h"

#ifdef UNITTEST_NO_EXCEPTIONS
#include <csetjmp>
#include <csetjmp>
#endif

namespace UnitTest {
Expand Down
4 changes: 2 additions & 2 deletions UnitTest++/TimeHelpers.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Config.h"

#if defined UNITTEST_POSIX
#include "Posix/TimeHelpers.h"
#include "Posix/TimeHelpers.h"
#else
#include "Win32/TimeHelpers.h"
#include "Win32/TimeHelpers.h"
#endif
48 changes: 24 additions & 24 deletions tests/TestTestMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ using namespace std;
/* test for c++11 support */
#ifndef _MSC_VER

/* Test for clang >= 3.3 */
#ifdef __clang__
#if (__clang__ == 1) && (__clang_major__ > 3 || (__clang_major__ == 3 && (__clang_minor__ > 2 )))
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif
#endif

#ifndef __clang__
/* Test for GCC >= 4.8.0 */
#ifdef __GNUC__
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif
#endif
#endif
/* Test for clang >= 3.3 */
#ifdef __clang__
#if (__clang__ == 1) && (__clang_major__ > 3 || (__clang_major__ == 3 && (__clang_minor__ > 2 )))
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif
#endif

#ifndef __clang__
/* Test for GCC >= 4.8.0 */
#ifdef __GNUC__
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif
#endif
#endif

#elif _MSC_VER

#if (_MSC_VER > 1800)
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif
#if (_MSC_VER > 1800)
#define _NOEXCEPT_OP(x) noexcept(x)
#else
#define _NOEXCEPT_OP(x)
#endif

#endif

Expand Down

0 comments on commit bb7555c

Please sign in to comment.