Commit 8965a6a0 authored by vladlosev's avatar vladlosev
Browse files

Improves conformance to the Google C++ Style Guide (by Greg Miller).

parent 829402ed
...@@ -3864,7 +3864,6 @@ int UnitTest::Run() { ...@@ -3864,7 +3864,6 @@ int UnitTest::Run() {
// process. In either case the user does not want to see pop-up dialogs // process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected. // about crashes - they are expected.
if (impl()->catch_exceptions() || in_death_test_child_process) { if (impl()->catch_exceptions() || in_death_test_child_process) {
# if !GTEST_OS_WINDOWS_MOBILE # if !GTEST_OS_WINDOWS_MOBILE
// SetErrorMode doesn't exist on CE. // SetErrorMode doesn't exist on CE.
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
...@@ -3895,7 +3894,6 @@ int UnitTest::Run() { ...@@ -3895,7 +3894,6 @@ int UnitTest::Run() {
0x0, // Clear the following flags: 0x0, // Clear the following flags:
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
# endif # endif
} }
#endif // GTEST_HAS_SEH #endif // GTEST_HAS_SEH
......
...@@ -27,13 +27,12 @@ ...@@ -27,13 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream> #include <stdio.h>
#include "gtest/gtest.h" #include "gtest/gtest.h"
GTEST_API_ int main(int argc, char **argv) { GTEST_API_ int main(int argc, char **argv) {
std::cout << "Running main() from gtest_main.cc\n"; printf("Running main() from gtest_main.cc\n");
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
...@@ -896,6 +896,7 @@ class MockDeathTest : public DeathTest { ...@@ -896,6 +896,7 @@ class MockDeathTest : public DeathTest {
virtual void Abort(AbortReason reason) { virtual void Abort(AbortReason reason) {
parent_->abort_args_.push_back(reason); parent_->abort_args_.push_back(reason);
} }
private: private:
MockDeathTestFactory* const parent_; MockDeathTestFactory* const parent_;
const TestRole role_; const TestRole role_;
......
...@@ -148,8 +148,7 @@ TEST_F(LinkedPtrTest, GeneralTest) { ...@@ -148,8 +148,7 @@ TEST_F(LinkedPtrTest, GeneralTest) {
"A0 dtor\n" "A0 dtor\n"
"A3 dtor\n" "A3 dtor\n"
"A1 dtor\n", "A1 dtor\n",
history->GetString().c_str() history->GetString().c_str());
);
} }
} // Unnamed namespace } // Unnamed namespace
...@@ -55,7 +55,7 @@ namespace internal { ...@@ -55,7 +55,7 @@ namespace internal {
class EventRecordingListener : public TestEventListener { class EventRecordingListener : public TestEventListener {
public: public:
EventRecordingListener(const char* name) : name_(name) {} explicit EventRecordingListener(const char* name) : name_(name) {}
protected: protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {
......
...@@ -606,6 +606,7 @@ class TestGenerationEnvironment : public ::testing::Environment { ...@@ -606,6 +606,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
<< "has not been run as expected."; << "has not been run as expected.";
} }
} }
private: private:
TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0), TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0),
tear_down_count_(0), test_body_count_(0) {} tear_down_count_(0), test_body_count_(0) {}
...@@ -674,6 +675,7 @@ class TestGenerationTest : public TestWithParam<int> { ...@@ -674,6 +675,7 @@ class TestGenerationTest : public TestWithParam<int> {
EXPECT_TRUE(collected_parameters_ == expected_values); EXPECT_TRUE(collected_parameters_ == expected_values);
} }
protected: protected:
int current_parameter_; int current_parameter_;
static vector<int> collected_parameters_; static vector<int> collected_parameters_;
......
...@@ -43,12 +43,14 @@ ...@@ -43,12 +43,14 @@
// Test fixture for testing definition and instantiation of a test // Test fixture for testing definition and instantiation of a test
// in separate translation units. // in separate translation units.
class ExternalInstantiationTest : public ::testing::TestWithParam<int> {}; class ExternalInstantiationTest : public ::testing::TestWithParam<int> {
};
// Test fixture for testing instantiation of a test in multiple // Test fixture for testing instantiation of a test in multiple
// translation units. // translation units.
class InstantiationInMultipleTranslaionUnitsTest class InstantiationInMultipleTranslaionUnitsTest
: public ::testing::TestWithParam<int> {}; : public ::testing::TestWithParam<int> {
};
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
......
...@@ -92,7 +92,7 @@ TEST(ImplicitCastTest, CanUseInheritance) { ...@@ -92,7 +92,7 @@ TEST(ImplicitCastTest, CanUseInheritance) {
class Castable { class Castable {
public: public:
Castable(bool* converted) : converted_(converted) {} explicit Castable(bool* converted) : converted_(converted) {}
operator Base() { operator Base() {
*converted_ = true; *converted_ = true;
return Base(); return Base();
...@@ -111,7 +111,7 @@ TEST(ImplicitCastTest, CanUseNonConstCastOperator) { ...@@ -111,7 +111,7 @@ TEST(ImplicitCastTest, CanUseNonConstCastOperator) {
class ConstCastable { class ConstCastable {
public: public:
ConstCastable(bool* converted) : converted_(converted) {} explicit ConstCastable(bool* converted) : converted_(converted) {}
operator Base() const { operator Base() const {
*converted_ = true; *converted_ = true;
return Base(); return Base();
...@@ -224,7 +224,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) { ...@@ -224,7 +224,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
GTEST_CHECK_(true); GTEST_CHECK_(true);
} }
switch(0) switch (0)
case 0: case 0:
GTEST_CHECK_(true) << "Check failed in switch case"; GTEST_CHECK_(true) << "Check failed in switch case";
} }
...@@ -929,7 +929,7 @@ TEST(CaptureTest, CapturesStdoutAndStderr) { ...@@ -929,7 +929,7 @@ TEST(CaptureTest, CapturesStdoutAndStderr) {
TEST(CaptureDeathTest, CannotReenterStdoutCapture) { TEST(CaptureDeathTest, CannotReenterStdoutCapture) {
CaptureStdout(); CaptureStdout();
EXPECT_DEATH_IF_SUPPORTED(CaptureStdout();, EXPECT_DEATH_IF_SUPPORTED(CaptureStdout(),
"Only one stdout capturer can exist at a time"); "Only one stdout capturer can exist at a time");
GetCapturedStdout(); GetCapturedStdout();
......
...@@ -841,7 +841,7 @@ TEST(PrintStlContainerTest, HashMultiSet) { ...@@ -841,7 +841,7 @@ TEST(PrintStlContainerTest, HashMultiSet) {
std::vector<int> numbers; std::vector<int> numbers;
for (size_t i = 0; i != result.length(); i++) { for (size_t i = 0; i != result.length(); i++) {
if (expected_pattern[i] == 'd') { if (expected_pattern[i] == 'd') {
ASSERT_TRUE(isdigit(static_cast<unsigned char>(result[i])) != 0); ASSERT_NE(isdigit(static_cast<unsigned char>(result[i])), 0);
numbers.push_back(result[i] - '0'); numbers.push_back(result[i] - '0');
} else { } else {
EXPECT_EQ(expected_pattern[i], result[i]) << " where result is " EXPECT_EQ(expected_pattern[i], result[i]) << " where result is "
......
...@@ -96,6 +96,7 @@ class MyEnvironment : public testing::Environment { ...@@ -96,6 +96,7 @@ class MyEnvironment : public testing::Environment {
// Was TearDown() run? // Was TearDown() run?
bool tear_down_was_run() const { return tear_down_was_run_; } bool tear_down_was_run() const { return tear_down_was_run_; }
private: private:
FailureType failure_in_set_up_; FailureType failure_in_set_up_;
bool set_up_was_run_; bool set_up_was_run_;
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
int main(int argc, char **argv) { int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
......
...@@ -378,6 +378,7 @@ class FatalFailureInFixtureConstructorTest : public testing::Test { ...@@ -378,6 +378,7 @@ class FatalFailureInFixtureConstructorTest : public testing::Test {
<< "We should never get here, as the test fixture c'tor " << "We should never get here, as the test fixture c'tor "
<< "had a fatal failure."; << "had a fatal failure.";
} }
private: private:
void Init() { void Init() {
FAIL() << "Expected failure #1, in the test fixture c'tor."; FAIL() << "Expected failure #1, in the test fixture c'tor.";
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // 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! // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h // Regression test for gtest_pred_impl.h
......
...@@ -71,7 +71,7 @@ namespace { ...@@ -71,7 +71,7 @@ namespace {
<< "Which is: " << expected_val << "\n";\ << "Which is: " << expected_val << "\n";\
::testing::internal::posix::Abort();\ ::testing::internal::posix::Abort();\
}\ }\
} while(::testing::internal::AlwaysFalse()) } while (::testing::internal::AlwaysFalse())
// Used for verifying that global environment set-up and tear-down are // Used for verifying that global environment set-up and tear-down are
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
// Google Test work. // Google Test work.
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <vector>
#include <ostream>
// Verifies that the command line flag variables can be accessed // Verifies that the command line flag variables can be accessed
// in code once <gtest/gtest.h> has been #included. // in code once <gtest/gtest.h> has been #included.
...@@ -58,6 +56,15 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { ...@@ -58,6 +56,15 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused. EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused.
} }
#include <limits.h> // For INT_MAX.
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <map>
#include <vector>
#include <ostream>
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's // Indicates that this translation unit is part of Google Test's
...@@ -69,13 +76,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { ...@@ -69,13 +76,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#include <limits.h> // For INT_MAX.
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <map>
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -1141,7 +1141,7 @@ TEST(StringTest, Equals) { ...@@ -1141,7 +1141,7 @@ TEST(StringTest, Equals) {
EXPECT_TRUE(foo == "foo"); // NOLINT EXPECT_TRUE(foo == "foo"); // NOLINT
const String bar("x\0y", 3); const String bar("x\0y", 3);
EXPECT_FALSE(bar == "x"); EXPECT_NE(bar, "x");
} }
// Tests String::operator!=(). // Tests String::operator!=().
...@@ -1163,7 +1163,7 @@ TEST(StringTest, NotEquals) { ...@@ -1163,7 +1163,7 @@ TEST(StringTest, NotEquals) {
EXPECT_FALSE(foo != "foo"); // NOLINT EXPECT_FALSE(foo != "foo"); // NOLINT
const String bar("x\0y", 3); const String bar("x\0y", 3);
EXPECT_TRUE(bar != "x"); EXPECT_NE(bar, "x");
} }
// Tests String::length(). // Tests String::length().
...@@ -1902,6 +1902,7 @@ class GTestFlagSaverTest : public Test { ...@@ -1902,6 +1902,7 @@ class GTestFlagSaverTest : public Test {
GTEST_FLAG(stream_result_to) = "localhost:1234"; GTEST_FLAG(stream_result_to) = "localhost:1234";
GTEST_FLAG(throw_on_failure) = true; GTEST_FLAG(throw_on_failure) = true;
} }
private: private:
// For saving Google Test flags during this test case. // For saving Google Test flags during this test case.
static GTestFlagSaver* saver_; static GTestFlagSaver* saver_;
...@@ -2797,7 +2798,6 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) { ...@@ -2797,7 +2798,6 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {
template <typename RawType> template <typename RawType>
class FloatingPointTest : public Test { class FloatingPointTest : public Test {
protected: protected:
// Pre-calculated numbers to be used by the tests. // Pre-calculated numbers to be used by the tests.
struct TestValues { struct TestValues {
RawType close_to_positive_zero; RawType close_to_positive_zero;
...@@ -7278,6 +7278,7 @@ TEST(ArrayEqTest, WorksForDegeneratedArrays) { ...@@ -7278,6 +7278,7 @@ TEST(ArrayEqTest, WorksForDegeneratedArrays) {
} }
TEST(ArrayEqTest, WorksForOneDimensionalArrays) { TEST(ArrayEqTest, WorksForOneDimensionalArrays) {
// Note that a and b are distinct but compatible types.
const int a[] = { 0, 1 }; const int a[] = { 0, 1 };
long b[] = { 0, 1 }; long b[] = { 0, 1 };
EXPECT_TRUE(ArrayEq(a, b)); EXPECT_TRUE(ArrayEq(a, b));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment