Skip to content

Commit

Permalink
Improves conformance to the Google C++ Style Guide (by Greg Miller).
Browse files Browse the repository at this point in the history
git-svn-id: http://googletest.googlecode.com/svn/trunk@607 861a406c-534a-0410-8894-cb66d6ee9925
  • Loading branch information
vladlosev committed Nov 4, 2011
1 parent f46f3ea commit 93fed47
Show file tree
Hide file tree
Showing 35 changed files with 144 additions and 91 deletions.
2 changes: 1 addition & 1 deletion include/gtest/gtest-spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class GTEST_API_ SingleFailureChecker {
(substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
&gtest_failures);\
if (::testing::internal::AlwaysTrue()) { statement; }\
}\
Expand Down
1 change: 1 addition & 0 deletions include/gtest/gtest-test-part.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class GTEST_API_ TestPartResult {

// Returns true iff the test part fatally failed.
bool fatally_failed() const { return type_ == kFatalFailure; }

private:
Type type_;

Expand Down
6 changes: 3 additions & 3 deletions include/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define GTEST_INCLUDE_GTEST_GTEST_H_

#include <limits>
#include <ostream>
#include <vector>

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

private:

#if GTEST_HAS_DEATH_TEST
friend class internal::DefaultDeathTestFactory;
#endif // GTEST_HAS_DEATH_TEST
Expand Down Expand Up @@ -1456,11 +1456,11 @@ GTEST_IMPL_CMP_HELPER_(NE, !=);
// Implements the helper function for {ASSERT|EXPECT}_LE
GTEST_IMPL_CMP_HELPER_(LE, <=);
// Implements the helper function for {ASSERT|EXPECT}_LT
GTEST_IMPL_CMP_HELPER_(LT, < );
GTEST_IMPL_CMP_HELPER_(LT, <);
// Implements the helper function for {ASSERT|EXPECT}_GE
GTEST_IMPL_CMP_HELPER_(GE, >=);
// Implements the helper function for {ASSERT|EXPECT}_GT
GTEST_IMPL_CMP_HELPER_(GT, > );
GTEST_IMPL_CMP_HELPER_(GT, >);

#undef GTEST_IMPL_CMP_HELPER_

Expand Down
12 changes: 6 additions & 6 deletions include/gtest/gtest_pred_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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

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

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

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

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

// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
Expand Down
4 changes: 2 additions & 2 deletions include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ class scoped_ptr {
ptr_ = p;
}
}

private:
T* ptr_;

Expand Down Expand Up @@ -1110,7 +1111,7 @@ class Notification {
// Blocks until the controller thread notifies. Must be called from a test
// thread.
void WaitForNotification() {
while(!notified_) {
while (!notified_) {
SleepMilliseconds(10);
}
}
Expand Down Expand Up @@ -1754,7 +1755,6 @@ class TypeWithSize<4> {
template <>
class TypeWithSize<8> {
public:

#if GTEST_OS_WINDOWS
typedef __int64 Int;
typedef unsigned __int64 UInt;
Expand Down
8 changes: 4 additions & 4 deletions include/gtest/internal/gtest-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
#endif

#include <string.h>
#include "gtest/internal/gtest-port.h"

#include <string>

#include "gtest/internal/gtest-port.h"

namespace testing {
namespace internal {

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

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

#if GTEST_HAS_GLOBAL_STRING
String(const ::string& str) {
String(const ::string& str) { // NOLINT
ConstructNonNull(str.c_str(), str.length());
}

Expand Down
88 changes: 66 additions & 22 deletions include/gtest/internal/gtest-tuple.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
// This file was GENERATED by command:
// pump.py gtest-tuple.h.pump
// DO NOT EDIT BY HAND!!!

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

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> {
typedef T0 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> {
typedef T1 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> {
typedef T2 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> {
typedef T3 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> {
typedef T4 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> {
typedef T5 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> {
typedef T6 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> {
typedef T7 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> {
typedef T8 type;
};

template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> {
typedef T9 type;
};

} // namespace gtest_internal

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

template <GTEST_0_TYPENAMES_(T)>
struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
struct tuple_size<GTEST_0_TUPLE_(T)> {
static const int value = 0;
};

template <GTEST_1_TYPENAMES_(T)>
struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
struct tuple_size<GTEST_1_TUPLE_(T)> {
static const int value = 1;
};

template <GTEST_2_TYPENAMES_(T)>
struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
struct tuple_size<GTEST_2_TUPLE_(T)> {
static const int value = 2;
};

template <GTEST_3_TYPENAMES_(T)>
struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
struct tuple_size<GTEST_3_TUPLE_(T)> {
static const int value = 3;
};

template <GTEST_4_TYPENAMES_(T)>
struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
struct tuple_size<GTEST_4_TUPLE_(T)> {
static const int value = 4;
};

template <GTEST_5_TYPENAMES_(T)>
struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
struct tuple_size<GTEST_5_TUPLE_(T)> {
static const int value = 5;
};

template <GTEST_6_TYPENAMES_(T)>
struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
struct tuple_size<GTEST_6_TUPLE_(T)> {
static const int value = 6;
};

template <GTEST_7_TYPENAMES_(T)>
struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
struct tuple_size<GTEST_7_TUPLE_(T)> {
static const int value = 7;
};

template <GTEST_8_TYPENAMES_(T)>
struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
struct tuple_size<GTEST_8_TUPLE_(T)> {
static const int value = 8;
};

template <GTEST_9_TYPENAMES_(T)>
struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
struct tuple_size<GTEST_9_TUPLE_(T)> {
static const int value = 9;
};

template <GTEST_10_TYPENAMES_(T)>
struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
struct tuple_size<GTEST_10_TUPLE_(T)> {
static const int value = 10;
};

template <int k, class Tuple>
struct tuple_element {
Expand Down
9 changes: 6 additions & 3 deletions include/gtest/internal/gtest-tuple.h.pump
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ struct TupleElement;

$for i [[
template <GTEST_$(n)_TYPENAMES_(T)>
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> [[]]
{ typedef T$i type; };
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> {
typedef T$i type;
};


]]
Expand Down Expand Up @@ -220,7 +221,9 @@ template <typename Tuple> struct tuple_size;

$for j [[
template <GTEST_$(j)_TYPENAMES_(T)>
struct tuple_size<GTEST_$(j)_TUPLE_(T)> { static const int value = $j; };
struct tuple_size<GTEST_$(j)_TUPLE_(T)> {
static const int value = $j;
};


]]
Expand Down
6 changes: 4 additions & 2 deletions include/gtest/internal/gtest-type-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ String GetTypeName() {
// so we have to demangle it.
# if GTEST_HAS_CXXABI_H_
using abi::__cxa_demangle;
# endif // GTEST_HAS_CXXABI_H_
# endif // GTEST_HAS_CXXABI_H_
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name);
free(readable_name);
Expand Down Expand Up @@ -3300,7 +3300,9 @@ struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
// INSTANTIATE_TYPED_TEST_CASE_P().

template <typename T>
struct TypeList { typedef Types1<T> type; };
struct TypeList {
typedef Types1<T> type;
};

template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10,
Expand Down
6 changes: 4 additions & 2 deletions include/gtest/internal/gtest-type-util.h.pump
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ String GetTypeName() {
// so we have to demangle it.
# if GTEST_HAS_CXXABI_H_
using abi::__cxa_demangle;
# endif // GTEST_HAS_CXXABI_H_
# endif // GTEST_HAS_CXXABI_H_
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name);
free(readable_name);
Expand Down Expand Up @@ -279,7 +279,9 @@ struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
// INSTANTIATE_TYPED_TEST_CASE_P().

template <typename T>
struct TypeList { typedef Types1<T> type; };
struct TypeList {
typedef Types1<T> type;
};


$range i 1..n
Expand Down
3 changes: 1 addition & 2 deletions samples/sample10_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class LeakChecker : public EmptyTestEventListener {
// You can generate a failure in any event handler except
// OnTestPartResult. Just use an appropriate Google Test assertion to do
// it.
EXPECT_TRUE(difference <= 0)
<< "Leaked " << difference << " unit(s) of Water!";
EXPECT_LE(difference, 0) << "Leaked " << difference << " unit(s) of Water!";
}

int initially_allocated_;
Expand Down
2 changes: 1 addition & 1 deletion samples/sample1_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ TEST(FactorialTest, Negative) {
// test case.
EXPECT_EQ(1, Factorial(-5));
EXPECT_EQ(1, Factorial(-1));
EXPECT_TRUE(Factorial(-10) > 0);
EXPECT_GT(Factorial(-10), 0);

// <TechnicalDetails>
//
Expand Down
1 change: 0 additions & 1 deletion samples/sample2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class MyString {
const MyString& operator=(const MyString& rhs);

public:

// Clones a 0-terminated C string, allocating memory using new.
static const char* CloneCString(const char* a_c_string);

Expand Down
Loading

0 comments on commit 93fed47

Please sign in to comment.