summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Johnmeyer <pjohnmeyer@gmail.com>2015-10-15 22:20:22 -0500
committerPatrick Johnmeyer <pjohnmeyer@gmail.com>2015-10-15 22:20:22 -0500
commitdc6b90838014ab985bf3cd74ac17ad9d00e1fbcb (patch)
tree23875a8a5e80339c07fd891f4c0caa4abdf7bfea
parentdab64862c4e1cad9a9273069feef40d48534a487 (diff)
parent0a14abb0a52cdfc9c849aadd121a07eb9e32c2a5 (diff)
downloadMicrosoft-unittest-cpp-upstream-master.tar.gz
Merge pull request #78 from Microsoft/vs2015Supportupstream-master
Vs2015 support
-rw-r--r--CMakeLists.txt15
-rw-r--r--UnitTest++/TimeConstraint.cpp4
-rw-r--r--UnitTest++/TimeConstraint.h8
-rw-r--r--tests/TestTestMacros.cpp26
-rw-r--r--tests/TestTimeConstraint.cpp8
5 files changed, 50 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f94881b..c573ef9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,21 @@ project(UnitTest++)
option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON)
+if(MSVC14 OR MSVC12)
+ # has the support we need
+else()
+ include(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ if(COMPILER_SUPPORTS_CXX14)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ elseif(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ else()
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+ endif()
+endif()
+
# get the main sources
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)
diff --git a/UnitTest++/TimeConstraint.cpp b/UnitTest++/TimeConstraint.cpp
index 1c12d83..f806aeb 100644
--- a/UnitTest++/TimeConstraint.cpp
+++ b/UnitTest++/TimeConstraint.cpp
@@ -6,8 +6,8 @@
namespace UnitTest {
-TimeConstraint::TimeConstraint(int ms, TestDetails const& details)
- : m_details(details)
+TimeConstraint::TimeConstraint(int ms, TestDetails const& details, int lineNumber)
+ : m_details(details, lineNumber)
, m_maxMs(ms)
{
m_timer.Start();
diff --git a/UnitTest++/TimeConstraint.h b/UnitTest++/TimeConstraint.h
index 8c06913..cf6d68a 100644
--- a/UnitTest++/TimeConstraint.h
+++ b/UnitTest++/TimeConstraint.h
@@ -3,16 +3,16 @@
#include "TimeHelpers.h"
#include "HelperMacros.h"
+#include "TestDetails.h"
namespace UnitTest {
class TestResults;
-class TestDetails;
class UNITTEST_LINKAGE TimeConstraint
{
public:
- TimeConstraint(int ms, TestDetails const& details);
+ TimeConstraint(int ms, TestDetails const& details, int lineNumber);
~TimeConstraint();
private:
@@ -20,12 +20,12 @@ private:
TimeConstraint(TimeConstraint const&);
Timer m_timer;
- TestDetails const& m_details;
+ TestDetails const m_details;
int const m_maxMs;
};
#define UNITTEST_TIME_CONSTRAINT(ms) \
- UnitTest::TimeConstraint unitTest__timeConstraint__(ms, UnitTest::TestDetails(m_details, __LINE__))
+ UnitTest::TimeConstraint unitTest__timeConstraint__(ms, m_details, __LINE__)
#define UNITTEST_TIME_CONSTRAINT_EXEMPT() \
UNITTEST_MULTILINE_MACRO_BEGIN \
diff --git a/tests/TestTestMacros.cpp b/tests/TestTestMacros.cpp
index 9a2cad2..f2fcbf0 100644
--- a/tests/TestTestMacros.cpp
+++ b/tests/TestTestMacros.cpp
@@ -10,6 +10,30 @@
using namespace UnitTest;
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
+#endif
+
namespace {
TestList list1;
@@ -143,7 +167,7 @@ TEST(FixturesWithThrowingCtorsAreFailures)
#if(_MSC_VER < 1900)
struct FixtureDtorThrows
{
- ~FixtureDtorThrows() { throw "exception"; }
+ ~FixtureDtorThrows() _NOEXCEPT_OP(false) { throw "exception"; }
};
TestList throwingFixtureTestList2;
diff --git a/tests/TestTimeConstraint.cpp b/tests/TestTimeConstraint.cpp
index 5cb6c16..ab93a05 100644
--- a/tests/TestTimeConstraint.cpp
+++ b/tests/TestTimeConstraint.cpp
@@ -14,7 +14,7 @@ TEST(TimeConstraintSucceedsWithFastTest)
TestResults result;
{
ScopedCurrentTest scopedResult(result);
- TimeConstraint t(200, TestDetails("", "", "", 0));
+ TimeConstraint t(200, TestDetails("", "", "", 0), 0);
TimeHelpers::SleepMs(5);
}
CHECK_EQUAL(0, result.GetFailureCount());
@@ -25,7 +25,7 @@ TEST(TimeConstraintFailsWithSlowTest)
TestResults result;
{
ScopedCurrentTest scopedResult(result);
- TimeConstraint t(10, TestDetails("", "", "", 0));
+ TimeConstraint t(10, TestDetails("", "", "", 0),0);
TimeHelpers::SleepMs(20);
}
CHECK_EQUAL(1, result.GetFailureCount());
@@ -39,7 +39,7 @@ TEST(TimeConstraintFailureIncludesCorrectData)
ScopedCurrentTest scopedResult(result);
TestDetails const details("testname", "suitename", "filename", 10);
- TimeConstraint t(10, details);
+ TimeConstraint t(10, details,10);
TimeHelpers::SleepMs(20);
}
@@ -56,7 +56,7 @@ TEST(TimeConstraintFailureIncludesTimeoutInformation)
TestResults result(&reporter);
{
ScopedCurrentTest scopedResult(result);
- TimeConstraint t(10, TestDetails("", "", "", 0));
+ TimeConstraint t(10, TestDetails("", "", "", 0),0);
TimeHelpers::SleepMs(20);
}