Skip to content

Commit 93fed47

Browse files
author
vladlosev
committed
Improves conformance to the Google C++ Style Guide (by Greg Miller).
git-svn-id: http://googletest.googlecode.com/svn/trunk@607 861a406c-534a-0410-8894-cb66d6ee9925
1 parent f46f3ea commit 93fed47

35 files changed

+144
-91
lines changed

include/gtest/gtest-spi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class GTEST_API_ SingleFailureChecker {
223223
(substr));\
224224
{\
225225
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
226-
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
226+
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
227227
&gtest_failures);\
228228
if (::testing::internal::AlwaysTrue()) { statement; }\
229229
}\

include/gtest/gtest-test-part.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class GTEST_API_ TestPartResult {
9696

9797
// Returns true iff the test part fatally failed.
9898
bool fatally_failed() const { return type_ == kFatalFailure; }
99+
99100
private:
100101
Type type_;
101102

include/gtest/gtest.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define GTEST_INCLUDE_GTEST_GTEST_H_
5353

5454
#include <limits>
55+
#include <ostream>
5556
#include <vector>
5657

5758
#include "gtest/internal/gtest-internal.h"
@@ -672,7 +673,6 @@ class GTEST_API_ TestInfo {
672673
const TestResult* result() const { return &result_; }
673674

674675
private:
675-
676676
#if GTEST_HAS_DEATH_TEST
677677
friend class internal::DefaultDeathTestFactory;
678678
#endif // GTEST_HAS_DEATH_TEST
@@ -1456,11 +1456,11 @@ GTEST_IMPL_CMP_HELPER_(NE, !=);
14561456
// Implements the helper function for {ASSERT|EXPECT}_LE
14571457
GTEST_IMPL_CMP_HELPER_(LE, <=);
14581458
// Implements the helper function for {ASSERT|EXPECT}_LT
1459-
GTEST_IMPL_CMP_HELPER_(LT, < );
1459+
GTEST_IMPL_CMP_HELPER_(LT, <);
14601460
// Implements the helper function for {ASSERT|EXPECT}_GE
14611461
GTEST_IMPL_CMP_HELPER_(GE, >=);
14621462
// Implements the helper function for {ASSERT|EXPECT}_GT
1463-
GTEST_IMPL_CMP_HELPER_(GT, > );
1463+
GTEST_IMPL_CMP_HELPER_(GT, >);
14641464

14651465
#undef GTEST_IMPL_CMP_HELPER_
14661466

include/gtest/gtest_pred_impl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
// This file is AUTOMATICALLY GENERATED on 09/24/2010 by command
30+
// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
3131
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
3232
//
3333
// Implements a family of generic predicate assertion macros.
@@ -98,7 +98,7 @@ AssertionResult AssertPred1Helper(const char* pred_text,
9898
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
9999
// Don't use this in your code.
100100
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
101-
GTEST_ASSERT_(pred_format(#v1, v1),\
101+
GTEST_ASSERT_(pred_format(#v1, v1), \
102102
on_failure)
103103

104104
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
@@ -144,7 +144,7 @@ AssertionResult AssertPred2Helper(const char* pred_text,
144144
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
145145
// Don't use this in your code.
146146
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
147-
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\
147+
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
148148
on_failure)
149149

150150
// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
@@ -197,7 +197,7 @@ AssertionResult AssertPred3Helper(const char* pred_text,
197197
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
198198
// Don't use this in your code.
199199
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
200-
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3),\
200+
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
201201
on_failure)
202202

203203
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
@@ -257,7 +257,7 @@ AssertionResult AssertPred4Helper(const char* pred_text,
257257
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
258258
// Don't use this in your code.
259259
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
260-
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
260+
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
261261
on_failure)
262262

263263
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
@@ -324,7 +324,7 @@ AssertionResult AssertPred5Helper(const char* pred_text,
324324
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
325325
// Don't use this in your code.
326326
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
327-
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
327+
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
328328
on_failure)
329329

330330
// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use

include/gtest/internal/gtest-port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ class scoped_ptr {
812812
ptr_ = p;
813813
}
814814
}
815+
815816
private:
816817
T* ptr_;
817818

@@ -1110,7 +1111,7 @@ class Notification {
11101111
// Blocks until the controller thread notifies. Must be called from a test
11111112
// thread.
11121113
void WaitForNotification() {
1113-
while(!notified_) {
1114+
while (!notified_) {
11141115
SleepMilliseconds(10);
11151116
}
11161117
}
@@ -1754,7 +1755,6 @@ class TypeWithSize<4> {
17541755
template <>
17551756
class TypeWithSize<8> {
17561757
public:
1757-
17581758
#if GTEST_OS_WINDOWS
17591759
typedef __int64 Int;
17601760
typedef unsigned __int64 UInt;

include/gtest/internal/gtest-string.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
#endif
4848

4949
#include <string.h>
50-
#include "gtest/internal/gtest-port.h"
51-
5250
#include <string>
5351

52+
#include "gtest/internal/gtest-port.h"
53+
5454
namespace testing {
5555
namespace internal {
5656

@@ -223,14 +223,14 @@ class GTEST_API_ String {
223223
// Converting a ::std::string or ::string containing an embedded NUL
224224
// character to a String will result in the prefix up to the first
225225
// NUL character.
226-
String(const ::std::string& str) {
226+
String(const ::std::string& str) { // NOLINT
227227
ConstructNonNull(str.c_str(), str.length());
228228
}
229229

230230
operator ::std::string() const { return ::std::string(c_str(), length()); }
231231

232232
#if GTEST_HAS_GLOBAL_STRING
233-
String(const ::string& str) {
233+
String(const ::string& str) { // NOLINT
234234
ConstructNonNull(str.c_str(), str.length());
235235
}
236236

include/gtest/internal/gtest-tuple.h

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
1+
// This file was GENERATED by command:
2+
// pump.py gtest-tuple.h.pump
3+
// DO NOT EDIT BY HAND!!!
24

35
// Copyright 2009 Google Inc.
46
// All Rights Reserved.
@@ -140,34 +142,54 @@ template <bool kIndexValid, int kIndex, class Tuple>
140142
struct TupleElement;
141143

142144
template <GTEST_10_TYPENAMES_(T)>
143-
struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
145+
struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> {
146+
typedef T0 type;
147+
};
144148

145149
template <GTEST_10_TYPENAMES_(T)>
146-
struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
150+
struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> {
151+
typedef T1 type;
152+
};
147153

148154
template <GTEST_10_TYPENAMES_(T)>
149-
struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
155+
struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> {
156+
typedef T2 type;
157+
};
150158

151159
template <GTEST_10_TYPENAMES_(T)>
152-
struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
160+
struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> {
161+
typedef T3 type;
162+
};
153163

154164
template <GTEST_10_TYPENAMES_(T)>
155-
struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
165+
struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> {
166+
typedef T4 type;
167+
};
156168

157169
template <GTEST_10_TYPENAMES_(T)>
158-
struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
170+
struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> {
171+
typedef T5 type;
172+
};
159173

160174
template <GTEST_10_TYPENAMES_(T)>
161-
struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
175+
struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> {
176+
typedef T6 type;
177+
};
162178

163179
template <GTEST_10_TYPENAMES_(T)>
164-
struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
180+
struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> {
181+
typedef T7 type;
182+
};
165183

166184
template <GTEST_10_TYPENAMES_(T)>
167-
struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
185+
struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> {
186+
typedef T8 type;
187+
};
168188

169189
template <GTEST_10_TYPENAMES_(T)>
170-
struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
190+
struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> {
191+
typedef T9 type;
192+
};
171193

172194
} // namespace gtest_internal
173195

@@ -708,37 +730,59 @@ inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
708730
template <typename Tuple> struct tuple_size;
709731

710732
template <GTEST_0_TYPENAMES_(T)>
711-
struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
733+
struct tuple_size<GTEST_0_TUPLE_(T)> {
734+
static const int value = 0;
735+
};
712736

713737
template <GTEST_1_TYPENAMES_(T)>
714-
struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
738+
struct tuple_size<GTEST_1_TUPLE_(T)> {
739+
static const int value = 1;
740+
};
715741

716742
template <GTEST_2_TYPENAMES_(T)>
717-
struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
743+
struct tuple_size<GTEST_2_TUPLE_(T)> {
744+
static const int value = 2;
745+
};
718746

719747
template <GTEST_3_TYPENAMES_(T)>
720-
struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
748+
struct tuple_size<GTEST_3_TUPLE_(T)> {
749+
static const int value = 3;
750+
};
721751

722752
template <GTEST_4_TYPENAMES_(T)>
723-
struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
753+
struct tuple_size<GTEST_4_TUPLE_(T)> {
754+
static const int value = 4;
755+
};
724756

725757
template <GTEST_5_TYPENAMES_(T)>
726-
struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
758+
struct tuple_size<GTEST_5_TUPLE_(T)> {
759+
static const int value = 5;
760+
};
727761

728762
template <GTEST_6_TYPENAMES_(T)>
729-
struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
763+
struct tuple_size<GTEST_6_TUPLE_(T)> {
764+
static const int value = 6;
765+
};
730766

731767
template <GTEST_7_TYPENAMES_(T)>
732-
struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
768+
struct tuple_size<GTEST_7_TUPLE_(T)> {
769+
static const int value = 7;
770+
};
733771

734772
template <GTEST_8_TYPENAMES_(T)>
735-
struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
773+
struct tuple_size<GTEST_8_TUPLE_(T)> {
774+
static const int value = 8;
775+
};
736776

737777
template <GTEST_9_TYPENAMES_(T)>
738-
struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
778+
struct tuple_size<GTEST_9_TUPLE_(T)> {
779+
static const int value = 9;
780+
};
739781

740782
template <GTEST_10_TYPENAMES_(T)>
741-
struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
783+
struct tuple_size<GTEST_10_TUPLE_(T)> {
784+
static const int value = 10;
785+
};
742786

743787
template <int k, class Tuple>
744788
struct tuple_element {

include/gtest/internal/gtest-tuple.h.pump

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ struct TupleElement;
118118

119119
$for i [[
120120
template <GTEST_$(n)_TYPENAMES_(T)>
121-
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> [[]]
122-
{ typedef T$i type; };
121+
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> {
122+
typedef T$i type;
123+
};
123124

124125

125126
]]
@@ -220,7 +221,9 @@ template <typename Tuple> struct tuple_size;
220221

221222
$for j [[
222223
template <GTEST_$(j)_TYPENAMES_(T)>
223-
struct tuple_size<GTEST_$(j)_TUPLE_(T)> { static const int value = $j; };
224+
struct tuple_size<GTEST_$(j)_TUPLE_(T)> {
225+
static const int value = $j;
226+
};
224227

225228

226229
]]

include/gtest/internal/gtest-type-util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ String GetTypeName() {
7272
// so we have to demangle it.
7373
# if GTEST_HAS_CXXABI_H_
7474
using abi::__cxa_demangle;
75-
# endif // GTEST_HAS_CXXABI_H_
75+
# endif // GTEST_HAS_CXXABI_H_
7676
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
7777
const String name_str(status == 0 ? readable_name : name);
7878
free(readable_name);
@@ -3300,7 +3300,9 @@ struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
33003300
// INSTANTIATE_TYPED_TEST_CASE_P().
33013301

33023302
template <typename T>
3303-
struct TypeList { typedef Types1<T> type; };
3303+
struct TypeList {
3304+
typedef Types1<T> type;
3305+
};
33043306

33053307
template <typename T1, typename T2, typename T3, typename T4, typename T5,
33063308
typename T6, typename T7, typename T8, typename T9, typename T10,

include/gtest/internal/gtest-type-util.h.pump

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ String GetTypeName() {
7070
// so we have to demangle it.
7171
# if GTEST_HAS_CXXABI_H_
7272
using abi::__cxa_demangle;
73-
# endif // GTEST_HAS_CXXABI_H_
73+
# endif // GTEST_HAS_CXXABI_H_
7474
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
7575
const String name_str(status == 0 ? readable_name : name);
7676
free(readable_name);
@@ -279,7 +279,9 @@ struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
279279
// INSTANTIATE_TYPED_TEST_CASE_P().
280280

281281
template <typename T>
282-
struct TypeList { typedef Types1<T> type; };
282+
struct TypeList {
283+
typedef Types1<T> type;
284+
};
283285

284286

285287
$range i 1..n

samples/sample10_unittest.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ class LeakChecker : public EmptyTestEventListener {
8989
// You can generate a failure in any event handler except
9090
// OnTestPartResult. Just use an appropriate Google Test assertion to do
9191
// it.
92-
EXPECT_TRUE(difference <= 0)
93-
<< "Leaked " << difference << " unit(s) of Water!";
92+
EXPECT_LE(difference, 0) << "Leaked " << difference << " unit(s) of Water!";
9493
}
9594

9695
int initially_allocated_;

samples/sample1_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ TEST(FactorialTest, Negative) {
8181
// test case.
8282
EXPECT_EQ(1, Factorial(-5));
8383
EXPECT_EQ(1, Factorial(-1));
84-
EXPECT_TRUE(Factorial(-10) > 0);
84+
EXPECT_GT(Factorial(-10), 0);
8585

8686
// <TechnicalDetails>
8787
//

samples/sample2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class MyString {
4444
const MyString& operator=(const MyString& rhs);
4545

4646
public:
47-
4847
// Clones a 0-terminated C string, allocating memory using new.
4948
static const char* CloneCString(const char* a_c_string);
5049

0 commit comments

Comments
 (0)