summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-11-04 17:56:23 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-11-04 17:56:23 +0000
commit93fed47dbf8e6bc3d39d3f769cb5039551747257 (patch)
treeab0e0f5e0fd23697673ec2e0edca67079375dd2c /test
parentf46f3eaf059b7b3ca00a3428c594bd477bc1839c (diff)
downloadgtest-93fed47dbf8e6bc3d39d3f769cb5039551747257.tar.gz
gtest-93fed47dbf8e6bc3d39d3f769cb5039551747257.tar.bz2
gtest-93fed47dbf8e6bc3d39d3f769cb5039551747257.tar.xz
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
Diffstat (limited to 'test')
-rw-r--r--test/gtest-death-test_test.cc1
-rw-r--r--test/gtest-linked_ptr_test.cc3
-rw-r--r--test/gtest-listener_test.cc2
-rw-r--r--test/gtest-param-test_test.cc2
-rw-r--r--test/gtest-param-test_test.h6
-rw-r--r--test/gtest-port_test.cc8
-rw-r--r--test/gtest-printers_test.cc2
-rw-r--r--test/gtest_environment_test.cc1
-rw-r--r--test/gtest_no_test_unittest.cc1
-rw-r--r--test/gtest_output_test_.cc1
-rw-r--r--test/gtest_pred_impl_unittest.cc2
-rw-r--r--test/gtest_repeat_test.cc2
-rw-r--r--test/gtest_unittest.cc25
13 files changed, 31 insertions, 25 deletions
diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc
index 54f5a1a..5a4a989 100644
--- a/test/gtest-death-test_test.cc
+++ b/test/gtest-death-test_test.cc
@@ -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_;
diff --git a/test/gtest-linked_ptr_test.cc b/test/gtest-linked_ptr_test.cc
index 0d5508a..6fcf512 100644
--- a/test/gtest-linked_ptr_test.cc
+++ b/test/gtest-linked_ptr_test.cc
@@ -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
diff --git a/test/gtest-listener_test.cc b/test/gtest-listener_test.cc
index 2aa08ef..1008608 100644
--- a/test/gtest-listener_test.cc
+++ b/test/gtest-listener_test.cc
@@ -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*/) {
diff --git a/test/gtest-param-test_test.cc b/test/gtest-param-test_test.cc
index 94a53d9..cf61866 100644
--- a/test/gtest-param-test_test.cc
+++ b/test/gtest-param-test_test.cc
@@ -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_;
diff --git a/test/gtest-param-test_test.h b/test/gtest-param-test_test.h
index d0f6556..26ea122 100644
--- a/test/gtest-param-test_test.h
+++ b/test/gtest-param-test_test.h
@@ -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
diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc
index b0177cf..75471c3 100644
--- a/test/gtest-port_test.cc
+++ b/test/gtest-port_test.cc
@@ -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();
diff --git a/test/gtest-printers_test.cc b/test/gtest-printers_test.cc
index 58044ab..58d9622 100644
--- a/test/gtest-printers_test.cc
+++ b/test/gtest-printers_test.cc
@@ -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 "
diff --git a/test/gtest_environment_test.cc b/test/gtest_environment_test.cc
index ec9aa2c..3cff19e 100644
--- a/test/gtest_environment_test.cc
+++ b/test/gtest_environment_test.cc
@@ -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_;
diff --git a/test/gtest_no_test_unittest.cc b/test/gtest_no_test_unittest.cc
index e3a85f1..292599a 100644
--- a/test/gtest_no_test_unittest.cc
+++ b/test/gtest_no_test_unittest.cc
@@ -34,7 +34,6 @@
#include "gtest/gtest.h"
-
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
diff --git a/test/gtest_output_test_.cc b/test/gtest_output_test_.cc
index 13dbec4..031ae83 100644
--- a/test/gtest_output_test_.cc
+++ b/test/gtest_output_test_.cc
@@ -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.";
diff --git a/test/gtest_pred_impl_unittest.cc b/test/gtest_pred_impl_unittest.cc
index 35dc9bc..a84eff8 100644
--- a/test/gtest_pred_impl_unittest.cc
+++ b/test/gtest_pred_impl_unittest.cc
@@ -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
diff --git a/test/gtest_repeat_test.cc b/test/gtest_repeat_test.cc
index 5223dc0..481012a 100644
--- a/test/gtest_repeat_test.cc
+++ b/test/gtest_repeat_test.cc
@@ -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
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 0d624fd..8cd58be 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -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));