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