8000 Merge pull request #78 from Microsoft/vs2015Support · unittest-cpp/unittest-cpp@dc6b908 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc6b908

Browse files
committed
Merge pull request #78 from Microsoft/vs2015Support
Vs2015 support
2 parents dab6486 + 0a14abb commit dc6b908

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ project(UnitTest++)
33

44
option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON)
55

6+
if(MSVC14 OR MSVC12)
7+
# has the support we need
8+
else()
9+
include(CheckCXXCompilerFlag)
10+
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
11+
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
12+
if(COMPILER_SUPPORTS_CXX14)
13+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
14+
elseif(COMPILER_SUPPORTS_CXX11)
15+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
16+
else()
17+
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
18+
endif()
19+
endif()
20+
621
# get the main sources
722
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
823
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)

UnitTest++/TimeConstraint.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace UnitTest {
77

88

9-
TimeConstraint::TimeConstraint(int ms, TestDetails const& details)
10-
: m_details(details)
9+
TimeConstraint::TimeConstraint(int ms, TestDetails const& details, int lineNumber)
10+
: m_details(details, lineNumber)
1111
, m_maxMs(ms)
1212
{
1313
m_timer.Start();

UnitTest++/TimeConstraint.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33

44
#include "TimeHelpers.h"
55
#include "HelperMacros.h"
6+
#include "TestDetails.h"
67

78
namespace UnitTest {
89

910
class TestResults;
10-
class TestDetails;
1111

1212
class UNITTEST_LINKAGE TimeConstraint
1313
{
1414
public:
15-
TimeConstraint(int ms, TestDetails const& details);
15+
TimeConstraint(int ms, TestDetails const& details, int lineNumber);
1616
~TimeConstraint();
1717

1818
private:
1919
void operator=(TimeConstraint const&);
2020
TimeConstraint(TimeConstraint const&);
2121

2222
Timer m_timer;
23-
TestDetails const& m_details;
23+
TestDetails const m_details;
2424
int const m_maxMs;
2525
};
2626

2727
#define UNITTEST_TIME_CONSTRAINT(ms) \
28-
UnitTest::TimeConstraint unitTest__timeConstraint__(ms, UnitTest::TestDetails(m_details, __LINE__))
28+
UnitTest::TimeConstraint unitTest__timeConstraint__(ms, m_details, __LINE__)
2929

3030
#define UNITTEST_TIME_CONSTRAINT_EXEMPT() \
3131
UNITTEST_MULTILINE_MACRO_BEGIN \

tests/TestTestMacros.cpp

+25-1
9E88
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010
using namespace UnitTest;
1111
using namespace std;
1212

13+
/* test for c++11 support */
14+
#ifndef _MSC_VER
15+
16+
/* Test for clang >= 3.3 */
17+
#ifdef __clang__
18+
#if (__clang__ == 1) && (__clang_major__ > 3 || (__clang_major__ == 3 && (__clang_minor__ > 2 )))
19+
#define _NOEXCEPT_OP(x) noexcept(x)
20+
#else
21+
#define _NOEXCEPT_OP(x)
22+
#endif
23+
#endif
24+
25+
#ifndef __clang__
26+
/* Test for GCC >= 4.8.0 */
27+
#ifdef __GNUC__
28+
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
29+
#define _NOEXCEPT_OP(x) noexcept(x)
30+
#else
31+
#define _NOEXCEPT_OP(x)
32+
#endif
33+
#endif
34+
#endif
35+
#endif
36+
1337
namespace {
1438

1539
TestList list1;
@@ -143,7 +167,7 @@ TEST(FixturesWithThrowingCtorsAreFailures)
143167
#if(_MSC_VER < 1900)
144168
struct FixtureDtorThrows
145169
{
146-
~FixtureDtorThrows() { throw "exception"; }
170+
~FixtureDtorThrows() _NOEXCEPT_OP(false) { throw "exception"; }
147171
};
148172

149173
TestList throwingFixtureTestList2;

tests/TestTimeConstraint.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TEST(TimeConstraintSucceedsWithFastTest)
1414
TestResults result;
1515
{
1616
ScopedCurrentTest scopedResult(result);
17-
TimeConstraint t(200, TestDetails("", "", "", 0));
17+
TimeConstraint t(200, TestDetails("", "", "", 0), 0);
1818
TimeHelpers::SleepMs(5);
1919
}
2020
CHECK_EQUAL(0, result.GetFailureCount());
@@ -25,7 +25,7 @@ TEST(TimeConstraintFailsWithSlowTest)
2525
TestResults result;
2626
{
2727
ScopedCurrentTest scopedResult(result);
28-
TimeConstraint t(10, TestDetails("", "", "", 0));
28+
TimeConstraint t(10, TestDetails("", "", "", 0),0);
2929
TimeHelpers::SleepMs(20);
3030
}
3131
CHECK_EQUAL(1, result.GetFailureCount());
@@ -39,7 +39,7 @@ TEST(TimeConstraintFailureIncludesCorrectData)
3939
ScopedCurrentTest scopedResult(result);
4040

4141
TestDetails const details("testname", "suitename", "filename", 10);
42-
TimeConstraint t(10, details);
42+
TimeConstraint t(10, details,10);
4343
TimeHelpers::SleepMs(20);
4444
}
4545

@@ -56,7 +56,7 @@ TEST(TimeConstraintFailureIncludesTimeoutInformation)
5656
TestResults result(&reporter);
5757
{
5858
ScopedCurrentTest scopedResult(result);
59-
TimeConstraint t(10, TestDetails("", "", "", 0));
59+
TimeConstraint t(10, TestDetails("", "", "", 0),0);
6060
TimeHelpers::SleepMs(20);
6161
}
6262

0 commit comments

Comments
 (0)
0