8000 Added support for VS2015 · unittest-cpp/unittest-cpp@a32dd17 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit a32dd17

Browse files
author
Anna Gringauze
committed
Added support for VS2015
1 parent ae24d94 commit a32dd17

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

UnitTest++/TimeConstraint.cpp

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@
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+
/* Test for GCC >= 4.8.0 */
26+
#ifdef __GNUC__
27+
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
28+
#define _NOEXCEPT_OP(x) noexcept(x)
29+
#else
30+
#define _NOEXCEPT_OP(x)
31+
#endif
32+
#endif
33+
34+
#endif
35+
1336
namespace {
1437

1538
TestList list1;
@@ -138,7 +161,7 @@ TEST(FixturesWithThrowingCtorsAreFailures)
138161

139162
struct FixtureDtorThrows
140163
{
141-
~FixtureDtorThrows() { throw "exception"; }
164+
~FixtureDtorThrows() _NOEXCEPT_OP(false) { throw "exception"; }
142165
};
143166

144167
TestList throwingFixtureTestList2;

tests/TestTimeConstraint.cpp

Lines changed: 4 additions & 4 deletions
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