8000 Change preprocessor indent rules. · unittest-cpp/unittest-cpp@f82c403 · GitHub
[go: up one dir, main page]

Skip to content

Commit f82c403

Browse files
committed
Change preprocessor indent rules.
1 parent b47b4f7 commit f82c403

19 files changed

+115
-113
lines changed

.uncrustify

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ cmt_insert_func_header = ""
476476
cmt_insert_class_header = ""
477477
cmt_insert_oc_msg_header = ""
478478
cmt_insert_before_preproc = false
479-
pp_indent = add
480-
pp_indent_at_level = true
481-
pp_indent_count = 0
479+
pp_indent = remove
480+
pp_indent_at_level = false
481+
pp_indent_count = 3
482482
pp_space = ignore
483483
pp_space_count = 0
484484
pp_indent_region = 0

UnitTest++/CheckMacros.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@
3434
#error UnitTest++ redefines CHECK_ARRAY2D_CLOSE
3535
#endif
3636

37-
#define CHECK(value) \
38-
UNITTEST_MULTILINE_MACRO_BEGIN \
39-
UT_TRY \
40-
({ \
41-
if (!UnitTest::Check(value)) \
42-
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
43-
}) \
44-
UT_CATCH (std::exception, e, \
45-
{ \
46-
UnitTest::MemoryOutStream message; \
47-
message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \
48-
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
49-
message.GetText()); \
50-
}) \
51-
UT_CATCH_ALL \
52-
({ \
53-
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
54-
"Unhandled exception in CHECK(" #value ")"); \
55-
}) \
37+
#define CHECK(value) \
38+
UNITTEST_MULTILINE_MACRO_BEGIN \
39+
UT_TRY \
40+
({ \
41+
if (!UnitTest::Check(value)) \
42+
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
43+
}) \
44+
UT_CATCH (std::exception, e, \
45+
{ \
46+
UnitTest::MemoryOutStream message; \
47+
message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \
48+
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
49+
message.GetText()); \
50+
}) \
51+
UT_CATCH_ALL \
52+
({ \
53+
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
54+
"Unhandled exception in CHECK(" #value ")"); \
55+
}) \
5656
UNITTEST_MULTILINE_MACRO_END
5757

5858
#define CHECK_EQUAL(expected, actual) \
@@ -158,14 +158,14 @@
158158

159159
// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_NO_EXCEPTIONS isn't defined (see config.h)
160160
#ifndef UNITTEST_NO_EXCEPTIONS
161-
#define CHECK_THROW(expression, ExpectedExceptionType) \
162-
UNITTEST_MULTILINE_MACRO_BEGIN \
163-
bool caught_ = false; \
164-
try { expression; } \
165-
catch (ExpectedExceptionType const&) { caught_ = true; } \
166-
catch (...) {} \
167-
if (!caught_) \
168-
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected exception: \"" #ExpectedExceptionType "\" not thrown"); \
161+
#define CHECK_THROW(expression, ExpectedExceptionType) \
162+
UNITTEST_MULTILINE_MACRO_BEGIN \
163+
bool caught_ = false; \
164+
try { expression; } \
165+
catch (ExpectedExceptionType const&) { caught_ = true; } \
166+
catch (...) {} \
167+
if (!caught_) \
168+
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected exception: \"" #ExpectedExceptionType "\" not thrown"); \
169169
UNITTEST_MULTILINE_MACRO_END
170170

171171

UnitTest++/ExecuteTest.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ namespace UnitTest {
2525
if (isMockTest == false)
2626
CurrentTest::Details() = &details;
2727

28-
#ifdef UNITTEST_NO_EXCEPTIONS
28+
#ifdef UNITTEST_NO_EXCEPTIONS
2929
if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0)
3030
{
31-
#endif
32-
#ifndef UNITTEST_POSIX
31+
#endif
32+
#ifndef UNITTEST_POSIX
3333
UT_TRY({ testObject.RunImpl(); })
34-
#else
34+
#else
3535
UT_TRY
3636
({
3737
UNITTEST_THROW_SIGNALS_POSIX_ONLY
3838
testObject.RunImpl();
3939
})
40-
#endif
40+
#endif
4141
UT_CATCH(AssertException, e, { (void)e; })
4242
UT_CATCH(std::exception, e,
4343
{
@@ -49,9 +49,9 @@ namespace UnitTest {
4949
({
5050
CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed");
5151
})
52-
#ifdef UNITTEST_NO_EXCEPTIONS
52+
#ifdef UNITTEST_NO_EXCEPTIONS
5353
}
54-
#endif
54+
#endif
5555
}
5656

5757
}

UnitTest++/MemoryOutStream.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace UnitTest {
1616
m_text = this->str();
1717
}
1818

19-
#ifdef UNITTEST_COMPILER_IS_MSVC6
19+
#ifdef UNITTEST_COMPILER_IS_MSVC6
2020

2121
#define snprintf _snprintf
2222

@@ -41,7 +41,7 @@ namespace UnitTest {
4141
return FormatToStream(stream, "%I64u", n);
4242
}
4343

44-
#endif
44+
#endif
4545

4646
}
4747

@@ -135,32 +135,32 @@ namespace UnitTest {
135135
return *this;
136136
}
137137

138-
#ifdef UNITTEST_COMPILER_IS_MSVC6
138+
#ifdef UNITTEST_COMPILER_IS_MSVC6
139139
MemoryOutStream& MemoryOutStream::operator <<(__int64 const n)
140-
#else
140+
#else
141141
MemoryOutStream& MemoryOutStream::operator <<(long long const n)
142-
#endif
142+
#endif
143143
{
144-
#ifdef UNITTEST_WIN32
144+
#ifdef UNITTEST_WIN32
145145
FormatToStream(*this, "%I64d", n);
146-
#else
146+
#else
147147
FormatToStream(*this, "%lld", n);
148-
#endif
148+
#endif
149149

150150
return *this;
151151
}
152152

153-
#ifdef UNITTEST_COMPILER_IS_MSVC6
153+
#ifdef UNITTEST_COMPILER_IS_MSVC6
154154
MemoryOutStream& MemoryOutStream::operator <<(unsigned __int64 const n)
155-
#else
155+
#else
156156
MemoryOutStream& MemoryOutStream::operator <<(unsigned long long const n)
157-
#endif
157+
#endif
158158
{
159-
#ifdef UNITTEST_WIN32
159+
#ifdef UNITTEST_WIN32
160160
FormatToStream(*this, "%I64u", n);
161-
#else
161+
#else
162162
FormatToStream(*this, "%llu", n);
163-
#endif
163+
#endif
164164

165165
return *this;
166166
}

UnitTest++/MemoryOutStream.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ namespace UnitTest
2626
mutable std::string m_text;
2727
};
2828

29-
#ifdef UNITTEST_COMPILER_IS_MSVC6
29+
#ifdef UNITTEST_COMPILER_IS_MSVC6
3 F438 030
std::ostream& operator<<(std::ostream& stream, __int64 const n);
3131
std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n);
32-
#endif
32+
#endif
3333

3434
}
3535

@@ -57,13 +57,13 @@ namespace UnitTest
5757
MemoryOutStream& operator <<(int n);
5858
MemoryOutStream& operator <<(long n);
5959
MemoryOutStream& operator <<(unsigned long n);
60-
#ifdef UNITTEST_COMPILER_IS_MSVC6
60+
#ifdef UNITTEST_COMPILER_IS_MSVC6
6161
MemoryOutStream& operator <<(__int64 n);
6262
MemoryOutStream& operator <<(unsigned __int64 n);
63-
#else
63+
#else
6464
MemoryOutStream& operator <<(long long n);
6565
MemoryOutStream& operator <<(unsigned long long n);
66-
#endif
66+
#endif
6767
MemoryOutStream& operator <<(float f);
6868
MemoryOutStream& operator <<(double d);
6969
MemoryOutStream& operator <<(void const* p);

UnitTest++/Posix/SignalTranslator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ namespace UnitTest {
2626
struct sigaction m_old_SIGALRM_action;
2727
};
2828

29-
#if !defined (__GNUC__)
29+
#if !defined (__GNUC__)
3030
#define UNITTEST_EXTENSION
31-
#else
31+
#else
3232
#define UNITTEST_EXTENSION __extension__
33-
#endif
33+
#endif
3434

3535
#define UNITTEST_THROW_SIGNALS_POSIX_ONLY \
3636
UnitTest::SignalTranslator sig; \

UnitTest++/ReportAssert.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ namespace UnitTest {
2828

2929
namespace Detail {
3030

31-
#ifdef UNITTEST_NO_EXCEPTIONS
31+
#ifdef UNITTEST_NO_EXCEPTIONS
3232
UNITTEST_JMPBUF* GetAssertJmpBuf()
3333
{
3434
static UNITTEST_JMPBUF s_jmpBuf;
3535
return &s_jmpBuf;
3636
}
37-
#endif
37+
#endif
3838

3939
UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults,
4040
const TestDetails* testDetails,
@@ -50,11 +50,11 @@ namespace UnitTest {
5050

5151
ExpectAssert(false);
5252

53-
#ifndef UNITTEST_NO_EXCEPTIONS
53+
#ifndef UNITTEST_NO_EXCEPTIONS
5454
throw AssertException();
55-
#else
55+
#else
5656
UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET();
57-
#endif
57+
#endif
5858
}
5959

6060
UNITTEST_LINKAGE void ExpectAssert(bool expected)

UnitTest++/ReportAssertImpl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ namespace UnitTest {
2525

2626
UNITTEST_LINKAGE bool AssertExpected();
2727

28-
#ifdef UNITTEST_NO_EXCEPTIONS
28+
#ifdef UNITTEST_NO_EXCEPTIONS
2929
UNITT 10000 EST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf();
3030

31-
#ifdef UNITTEST_WIN32
31+
#ifdef UNITTEST_WIN32
3232
#define UNITTEST_SET_ASSERT_JUMP_TARGET() \
3333
__pragma(warning(push)) __pragma(warning(disable: 4611)) \
3434
UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \
3535
__pragma(warning(pop))
36-
#else
36+
#else
3737
#define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf())
38-
#endif
38+
#endif
3939

4040
#define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1)
41-
#endif
41+
#endif
4242

4343
}
4444
}

UnitTest++/TestReporterStdout.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace UnitTest {
1313
void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure)
1414
{
1515
using namespace std;
16-
#if defined(__APPLE__) || defined(__GNUG__)
16+
#if defined(__APPLE__) || defined(__GNUG__)
1717
char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n";
1818
fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure);
19-
#else
19+
#else
2020
char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
2121
fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure);
22-
#endif
22+
#endif
2323
}
2424

2525
void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)

UnitTest++/Win32/TimeHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace UnitTest {
99
: m_threadHandle(::GetCurrentThread())
1010
, m_startTime(0)
1111
{
12-
#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR
12+
#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR
1313
typedef unsigned long DWORD_PTR;
14-
#endif
14+
#endif
1515

1616
DWORD_PTR systemMask;
1717
::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask);

UnitTest++/Win32/TimeHelpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ namespace UnitTest {
2424

2525
void* m_threadHandle;
2626

27-
#if defined(_WIN64)
27+
#if defined(_WIN64)
2828
unsigned __int64 m_processAffinityMask;
29-
#else
29+
#else
3030
unsigned long m_processAffinityMask;
31-
#endif
31+
#endif
3232

3333
__int64 m_startTime;
3434
__int64 m_frequency;

tests/ScopedCurrentTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class ScopedCurrentTest
1919
UnitTest::CurrentTest::Results() = &newResults;
2020

2121
if (newDetails != NULL)
22+
{
2223
UnitTest::CurrentTest::Details() = newDetails;
24+
}
2325
}
2426

2527
~ScopedCurrentTest()

tests/TestAssertHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace {
2121
CHECK(!Detail::AssertExpected());
2222
}
2323

24-
#ifndef UNITTEST_NO_EXCEPTIONS
24+
#ifndef UNITTEST_NO_EXCEPTIONS
2525

2626
TEST(ReportAssertThrowsAssertException)
2727
{
@@ -107,7 +107,7 @@ namespace {
107107
Detail::ExpectAssert(false);
108108
}
109109

110-
#else
110+
#else
111111

112112
TEST(SetAssertJumpTargetReturnsFalseWhenSettingJumpTarget)
113113
{
@@ -128,6 +128,6 @@ namespace {
128128
CHECK(set == false);
129129
}
130130

131-
#endif
131+
#endif
132132

133133
}

tests/TestDeferredTestReporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ namespace UnitTest
1212
namespace
1313
{
1414

15-
#ifndef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
15+
#ifndef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
1616
MemoryOutStream& operator <<(MemoryOutStream& lhs, const std::string& rhs)
1717
{
1818
lhs << rhs.c_str();
1919
return lhs;
2020
}
21-
#endif
21+
#endif
2222

2323
struct MockDeferredTestReporter : public DeferredTestReporter
2424
{

0 commit comments

Comments
 (0)
0