Commit 25905b9f authored by Gennadiy Civil's avatar Gennadiy Civil
Browse files

Merge branch 'master' of https://github.com/google/googletest

parents 4665eee1 3bedb5a9
...@@ -41,7 +41,6 @@ using ::testing::Test; ...@@ -41,7 +41,6 @@ using ::testing::Test;
using ::testing::TestEventListeners; using ::testing::TestEventListeners;
using ::testing::TestInfo; using ::testing::TestInfo;
using ::testing::UnitTest; using ::testing::UnitTest;
using ::testing::internal::scoped_ptr;
// The test methods are empty, as the sole purpose of this program is // The test methods are empty, as the sole purpose of this program is
// to print the test names before/after shuffling. // to print the test names before/after shuffling.
...@@ -77,12 +76,12 @@ TEST(DISABLED_D, DISABLED_B) {} ...@@ -77,12 +76,12 @@ TEST(DISABLED_D, DISABLED_B) {}
// iteration with a "----" marker. // iteration with a "----" marker.
class TestNamePrinter : public EmptyTestEventListener { class TestNamePrinter : public EmptyTestEventListener {
public: public:
virtual void OnTestIterationStart(const UnitTest& /* unit_test */, void OnTestIterationStart(const UnitTest& /* unit_test */,
int /* iteration */) { int /* iteration */) override {
printf("----\n"); printf("----\n");
} }
virtual void OnTestStart(const TestInfo& test_info) { void OnTestStart(const TestInfo& test_info) override {
printf("%s.%s\n", test_info.test_case_name(), test_info.name()); printf("%s.%s\n", test_info.test_case_name(), test_info.name());
} }
}; };
......
...@@ -121,7 +121,7 @@ TEST_F(TestPartResultTest, type) { ...@@ -121,7 +121,7 @@ TEST_F(TestPartResultTest, type) {
// Tests TestPartResult::file_name(). // Tests TestPartResult::file_name().
TEST_F(TestPartResultTest, file_name) { TEST_F(TestPartResultTest, file_name) {
EXPECT_STREQ("foo/bar.cc", r1_.file_name()); EXPECT_STREQ("foo/bar.cc", r1_.file_name());
EXPECT_STREQ(NULL, r3_.file_name()); EXPECT_STREQ(nullptr, r3_.file_name());
EXPECT_STREQ("foo/bar.cc", r4_.file_name()); EXPECT_STREQ("foo/bar.cc", r4_.file_name());
} }
......
...@@ -68,7 +68,7 @@ def SetEnvVar(env_var, value): ...@@ -68,7 +68,7 @@ def SetEnvVar(env_var, value):
def Run(command): def Run(command):
"""Runs a command; returns True/False if its exit code is/isn't 0.""" """Runs a command; returns True/False if its exit code is/isn't 0."""
print 'Running "%s". . .' % ' '.join(command) print('Running "%s". . .' % ' '.join(command))
p = gtest_test_utils.Subprocess(command) p = gtest_test_utils.Subprocess(command)
return p.exited and p.exit_code == 0 return p.exited and p.exit_code == 0
......
// Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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 "gtest/internal/gtest-tuple.h"
#include <utility>
#include "gtest/gtest.h"
namespace {
using ::std::tr1::get;
using ::std::tr1::make_tuple;
using ::std::tr1::tuple;
using ::std::tr1::tuple_element;
using ::std::tr1::tuple_size;
using ::testing::StaticAssertTypeEq;
// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.
TEST(tuple_element_Test, ReturnsElementType) {
StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();
StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();
StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();
}
// Tests that tuple_size<T>::value gives the number of fields in tuple
// type T.
TEST(tuple_size_Test, ReturnsNumberOfFields) {
EXPECT_EQ(0, +tuple_size<tuple<> >::value);
EXPECT_EQ(1, +tuple_size<tuple<void*> >::value);
EXPECT_EQ(1, +tuple_size<tuple<char> >::value);
EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value));
EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value));
EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value));
}
// Tests comparing a tuple with itself.
TEST(ComparisonTest, ComparesWithSelf) {
const tuple<int, char, bool> a(5, 'a', false);
EXPECT_TRUE(a == a);
EXPECT_FALSE(a != a);
}
// Tests comparing two tuples with the same value.
TEST(ComparisonTest, ComparesEqualTuples) {
const tuple<int, bool> a(5, true), b(5, true);
EXPECT_TRUE(a == b);
EXPECT_FALSE(a != b);
}
// Tests comparing two different tuples that have no reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {
typedef tuple<const int, char> FooTuple;
const FooTuple a(0, 'x');
const FooTuple b(1, 'a');
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
const FooTuple c(1, 'b');
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests comparing two different tuples that have reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {
typedef tuple<int&, const char&> FooTuple;
int i = 5;
const char ch = 'a';
const FooTuple a(i, ch);
int j = 6;
const FooTuple b(j, ch);
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
j = 5;
const char ch2 = 'b';
const FooTuple c(j, ch2);
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests that a tuple field with a reference type is an alias of the
// variable it's supposed to reference.
TEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {
int n = 0;
tuple<bool, int&> t(true, n);
n = 1;
EXPECT_EQ(n, get<1>(t))
<< "Changing a underlying variable should update the reference field.";
// Makes sure that the implementation doesn't do anything funny with
// the & operator for the return type of get<>().
EXPECT_EQ(&n, &(get<1>(t)))
<< "The address of a reference field should equal the address of "
<< "the underlying variable.";
get<1>(t) = 2;
EXPECT_EQ(2, n)
<< "Changing a reference field should update the underlying variable.";
}
// Tests that tuple's default constructor default initializes each field.
// This test needs to compile without generating warnings.
TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
// The TR1 report requires that tuple's default constructor default
// initializes each field, even if it's a primitive type. If the
// implementation forgets to do this, this test will catch it by
// generating warnings about using uninitialized variables (assuming
// a decent compiler).
tuple<> empty;
tuple<int> a1, b1;
b1 = a1;
EXPECT_EQ(0, get<0>(b1));
tuple<int, double> a2, b2;
b2 = a2;
EXPECT_EQ(0, get<0>(b2));
EXPECT_EQ(0.0, get<1>(b2));
tuple<double, char, bool*> a3, b3;
b3 = a3;
EXPECT_EQ(0.0, get<0>(b3));
EXPECT_EQ('\0', get<1>(b3));
EXPECT_TRUE(get<2>(b3) == nullptr);
tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;
b10 = a10;
EXPECT_EQ(0, get<0>(b10));
EXPECT_EQ(0, get<1>(b10));
EXPECT_EQ(0, get<2>(b10));
EXPECT_EQ(0, get<3>(b10));
EXPECT_EQ(0, get<4>(b10));
EXPECT_EQ(0, get<5>(b10));
EXPECT_EQ(0, get<6>(b10));
EXPECT_EQ(0, get<7>(b10));
EXPECT_EQ(0, get<8>(b10));
EXPECT_EQ(0, get<9>(b10));
}
// Tests constructing a tuple from its fields.
TEST(TupleConstructorTest, ConstructsFromFields) {
int n = 1;
// Reference field.
tuple<int&> a(n);
EXPECT_EQ(&n, &(get<0>(a)));
// Non-reference fields.
tuple<int, char> b(5, 'a');
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ('a', get<1>(b));
// Const reference field.
const int m = 2;
tuple<bool, const int&> c(true, m);
EXPECT_TRUE(get<0>(c));
EXPECT_EQ(&m, &(get<1>(c)));
}
// Tests tuple's copy constructor.
TEST(TupleConstructorTest, CopyConstructor) {
tuple<double, bool> a(0.0, true);
tuple<double, bool> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_TRUE(get<1>(b));
}
// Tests constructing a tuple from another tuple that has a compatible
// but different type.
TEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {
tuple<int, int, char> a(0, 1, 'a');
tuple<double, long, int> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_EQ(1, get<1>(b));
EXPECT_EQ('a', get<2>(b));
}
// Tests constructing a 2-tuple from an std::pair.
TEST(TupleConstructorTest, ConstructsFromPair) {
::std::pair<int, char> a(1, 'a');
tuple<int, char> b(a);
tuple<int, const char&> c(a);
}
// Tests assigning a tuple to another tuple with the same type.
TEST(TupleAssignmentTest, AssignsToSameTupleType) {
const tuple<int, long> a(5, 7L);
tuple<int, long> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ(7L, get<1>(b));
}
// Tests assigning a tuple to another tuple with a different but
// compatible type.
TEST(TupleAssignmentTest, AssignsToDifferentTupleType) {
const tuple<int, long, bool> a(1, 7L, true);
tuple<long, int, bool> b;
b = a;
EXPECT_EQ(1L, get<0>(b));
EXPECT_EQ(7, get<1>(b));
EXPECT_TRUE(get<2>(b));
}
// Tests assigning an std::pair to a 2-tuple.
TEST(TupleAssignmentTest, AssignsFromPair) {
const ::std::pair<int, bool> a(5, true);
tuple<int, bool> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_TRUE(get<1>(b));
tuple<long, bool> c;
c = a;
EXPECT_EQ(5L, get<0>(c));
EXPECT_TRUE(get<1>(c));
}
// A fixture for testing big tuples.
class BigTupleTest : public testing::Test {
protected:
typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;
BigTupleTest() :
a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),
b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}
BigTuple a_, b_;
};
// Tests constructing big tuples.
TEST_F(BigTupleTest, Construction) {
BigTuple a;
BigTuple b(b_);
}
// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.
TEST_F(BigTupleTest, get) {
EXPECT_EQ(1, get<0>(a_));
EXPECT_EQ(2, get<9>(a_));
// Tests that get() works on a const tuple too.
const BigTuple a(a_);
EXPECT_EQ(1, get<0>(a));
EXPECT_EQ(2, get<9>(a));
}
// Tests comparing big tuples.
TEST_F(BigTupleTest, Comparisons) {
EXPECT_TRUE(a_ == a_);
EXPECT_FALSE(a_ != a_);
EXPECT_TRUE(a_ != b_);
EXPECT_FALSE(a_ == b_);
}
TEST(MakeTupleTest, WorksForScalarTypes) {
tuple<bool, int> a;
a = make_tuple(true, 5);
EXPECT_TRUE(get<0>(a));
EXPECT_EQ(5, get<1>(a));
tuple<char, int, long> b;
b = make_tuple('a', 'b', 5);
EXPECT_EQ('a', get<0>(b));
EXPECT_EQ('b', get<1>(b));
EXPECT_EQ(5, get<2>(b));
}
TEST(MakeTupleTest, WorksForPointers) {
int a[] = { 1, 2, 3, 4 };
const char* const str = "hi";
int* const p = a;
tuple<const char*, int*> t;
t = make_tuple(str, p);
EXPECT_EQ(str, get<0>(t));
EXPECT_EQ(p, get<1>(t));
}
} // namespace
...@@ -43,8 +43,8 @@ def Assert(condition): ...@@ -43,8 +43,8 @@ def Assert(condition):
def AssertEq(expected, actual): def AssertEq(expected, actual):
if expected != actual: if expected != actual:
print 'Expected: %s' % (expected,) print('Expected: %s' % (expected,))
print ' Actual: %s' % (actual,) print(' Actual: %s' % (actual,))
raise AssertionError raise AssertionError
......
...@@ -68,14 +68,14 @@ class CommonTest : public Test { ...@@ -68,14 +68,14 @@ class CommonTest : public Test {
CommonTest() : value_(1) {} CommonTest() : value_(1) {}
virtual ~CommonTest() { EXPECT_EQ(3, value_); } ~CommonTest() override { EXPECT_EQ(3, value_); }
virtual void SetUp() { void SetUp() override {
EXPECT_EQ(1, value_); EXPECT_EQ(1, value_);
value_++; value_++;
} }
virtual void TearDown() { void TearDown() override {
EXPECT_EQ(2, value_); EXPECT_EQ(2, value_);
value_++; value_++;
} }
...@@ -215,7 +215,7 @@ using testing::internal::TypedTestCasePState; ...@@ -215,7 +215,7 @@ using testing::internal::TypedTestCasePState;
class TypedTestCasePStateTest : public Test { class TypedTestCasePStateTest : public Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
state_.AddTestName("foo.cc", 0, "FooTest", "A"); state_.AddTestName("foo.cc", 0, "FooTest", "A");
state_.AddTestName("foo.cc", 0, "FooTest", "B"); state_.AddTestName("foo.cc", 0, "FooTest", "B");
state_.AddTestName("foo.cc", 0, "FooTest", "C"); state_.AddTestName("foo.cc", 0, "FooTest", "C");
......
...@@ -232,7 +232,7 @@ TEST(DISABLED_Test, Dummy2) {} ...@@ -232,7 +232,7 @@ TEST(DISABLED_Test, Dummy2) {}
class FinalSuccessChecker : public Environment { class FinalSuccessChecker : public Environment {
protected: protected:
virtual void TearDown() { void TearDown() override {
UnitTest* unit_test = UnitTest::GetInstance(); UnitTest* unit_test = UnitTest::GetInstance();
EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count()); EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// Sometimes it's desirable to build most of Google Test's own tests // Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose. // by compiling a single file. This file serves this purpose.
#include "test/googletest-filepath-test.cc" #include "test/googletest-filepath-test.cc"
#include "test/googletest-linked-ptr-test.cc"
#include "test/googletest-message-test.cc" #include "test/googletest-message-test.cc"
#include "test/googletest-options-test.cc" #include "test/googletest-options-test.cc"
#include "test/googletest-port-test.cc" #include "test/googletest-port-test.cc"
......
...@@ -53,7 +53,7 @@ class MyEnvironment : public testing::Environment { ...@@ -53,7 +53,7 @@ class MyEnvironment : public testing::Environment {
// Depending on the value of failure_in_set_up_, SetUp() will // Depending on the value of failure_in_set_up_, SetUp() will
// generate a non-fatal failure, generate a fatal failure, or // generate a non-fatal failure, generate a fatal failure, or
// succeed. // succeed.
virtual void SetUp() { void SetUp() override {
set_up_was_run_ = true; set_up_was_run_ = true;
switch (failure_in_set_up_) { switch (failure_in_set_up_) {
...@@ -69,7 +69,7 @@ class MyEnvironment : public testing::Environment { ...@@ -69,7 +69,7 @@ class MyEnvironment : public testing::Environment {
} }
// Generates a non-fatal failure. // Generates a non-fatal failure.
virtual void TearDown() { void TearDown() override {
tear_down_was_run_ = true; tear_down_was_run_ = true;
ADD_FAILURE() << "Expected non-fatal failure in global tear-down."; ADD_FAILURE() << "Expected non-fatal failure in global tear-down.";
} }
......
...@@ -122,13 +122,13 @@ struct PredFormatFunctor1 { ...@@ -122,13 +122,13 @@ struct PredFormatFunctor1 {
class Predicate1Test : public testing::Test { class Predicate1Test : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
expected_to_finish_ = true; expected_to_finish_ = true;
finished_ = false; finished_ = false;
n1_ = 0; n1_ = 0;
} }
virtual void TearDown() { void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated // Verifies that each of the predicate's arguments was evaluated
// exactly once. // exactly once.
EXPECT_EQ(1, n1_) << EXPECT_EQ(1, n1_) <<
...@@ -514,13 +514,13 @@ struct PredFormatFunctor2 { ...@@ -514,13 +514,13 @@ struct PredFormatFunctor2 {
class Predicate2Test : public testing::Test { class Predicate2Test : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
expected_to_finish_ = true; expected_to_finish_ = true;
finished_ = false; finished_ = false;
n1_ = n2_ = 0; n1_ = n2_ = 0;
} }
virtual void TearDown() { void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated // Verifies that each of the predicate's arguments was evaluated
// exactly once. // exactly once.
EXPECT_EQ(1, n1_) << EXPECT_EQ(1, n1_) <<
...@@ -948,13 +948,13 @@ struct PredFormatFunctor3 { ...@@ -948,13 +948,13 @@ struct PredFormatFunctor3 {
class Predicate3Test : public testing::Test { class Predicate3Test : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
expected_to_finish_ = true; expected_to_finish_ = true;
finished_ = false; finished_ = false;
n1_ = n2_ = n3_ = 0; n1_ = n2_ = n3_ = 0;
} }
virtual void TearDown() { void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated // Verifies that each of the predicate's arguments was evaluated
// exactly once. // exactly once.
EXPECT_EQ(1, n1_) << EXPECT_EQ(1, n1_) <<
...@@ -1424,13 +1424,13 @@ struct PredFormatFunctor4 { ...@@ -1424,13 +1424,13 @@ struct PredFormatFunctor4 {
class Predicate4Test : public testing::Test { class Predicate4Test : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
expected_to_finish_ = true; expected_to_finish_ = true;
finished_ = false; finished_ = false;
n1_ = n2_ = n3_ = n4_ = 0; n1_ = n2_ = n3_ = n4_ = 0;
} }
virtual void TearDown() { void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated // Verifies that each of the predicate's arguments was evaluated
// exactly once. // exactly once.
EXPECT_EQ(1, n1_) << EXPECT_EQ(1, n1_) <<
...@@ -1942,13 +1942,13 @@ struct PredFormatFunctor5 { ...@@ -1942,13 +1942,13 @@ struct PredFormatFunctor5 {
class Predicate5Test : public testing::Test { class Predicate5Test : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
expected_to_finish_ = true; expected_to_finish_ = true;
finished_ = false; finished_ = false;
n1_ = n2_ = n3_ = n4_ = n5_ = 0; n1_ = n2_ = n3_ = n4_ = n5_ = 0;
} }
virtual void TearDown() { void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated // Verifies that each of the predicate's arguments was evaluated
// exactly once. // exactly once.
EXPECT_EQ(1, n1_) << EXPECT_EQ(1, n1_) <<
......
...@@ -74,8 +74,8 @@ int g_environment_tear_down_count = 0; ...@@ -74,8 +74,8 @@ int g_environment_tear_down_count = 0;
class MyEnvironment : public testing::Environment { class MyEnvironment : public testing::Environment {
public: public:
MyEnvironment() {} MyEnvironment() {}
virtual void SetUp() { g_environment_set_up_count++; } void SetUp() override { g_environment_set_up_count++; }
virtual void TearDown() { g_environment_tear_down_count++; } void TearDown() override { g_environment_tear_down_count++; }
}; };
// A test that should fail. // A test that should fail.
......
...@@ -32,7 +32,24 @@ ...@@ -32,7 +32,24 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
using ::testing::Test;
TEST(SkipTest, DoesSkip) { TEST(SkipTest, DoesSkip) {
GTEST_SKIP(); GTEST_SKIP();
EXPECT_EQ(0, 1); EXPECT_EQ(0, 1);
} }
class Fixture : public Test {
protected:
void SetUp() override {
GTEST_SKIP() << "skipping all tests for this fixture";
}
};
TEST_F(Fixture, SkipsOneTest) {
EXPECT_EQ(5, 7);
}
TEST_F(Fixture, SkipsAnotherTest) {
EXPECT_EQ(99, 100);
}
...@@ -45,7 +45,6 @@ namespace { ...@@ -45,7 +45,6 @@ namespace {
using internal::Notification; using internal::Notification;
using internal::TestPropertyKeyIs; using internal::TestPropertyKeyIs;
using internal::ThreadWithParam; using internal::ThreadWithParam;
using internal::scoped_ptr;
// In order to run tests in this file, for platforms where Google Test is // In order to run tests in this file, for platforms where Google Test is
// thread safe, implement ThreadWithParam. See the description of its API // thread safe, implement ThreadWithParam. See the description of its API
...@@ -119,7 +118,7 @@ void CheckTestFailureCount(int expected_failures) { ...@@ -119,7 +118,7 @@ void CheckTestFailureCount(int expected_failures) {
// concurrently. // concurrently.
TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) { TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {
{ {
scoped_ptr<ThreadWithParam<int> > threads[kThreadCount]; std::unique_ptr<ThreadWithParam<int> > threads[kThreadCount];
Notification threads_can_start; Notification threads_can_start;
for (int i = 0; i != kThreadCount; i++) for (int i = 0; i != kThreadCount; i++)
threads[i].reset(new ThreadWithParam<int>(&ManyAsserts, threads[i].reset(new ThreadWithParam<int>(&ManyAsserts,
......
...@@ -36,6 +36,7 @@ import sys ...@@ -36,6 +36,7 @@ import sys
IS_WINDOWS = os.name == 'nt' IS_WINDOWS = os.name == 'nt'
IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0] IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
IS_OS2 = os.name == 'os2'
import atexit import atexit
import shutil import shutil
...@@ -164,7 +165,7 @@ def GetTestExecutablePath(executable_name, build_dir=None): ...@@ -164,7 +165,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
path = os.path.abspath(os.path.join(build_dir or GetBuildDir(), path = os.path.abspath(os.path.join(build_dir or GetBuildDir(),
executable_name)) executable_name))
if (IS_WINDOWS or IS_CYGWIN) and not path.endswith('.exe'): if (IS_WINDOWS or IS_CYGWIN or IS_OS2) and not path.endswith('.exe'):
path += '.exe' path += '.exe'
if not os.path.exists(path): if not os.path.exists(path):
......
...@@ -78,7 +78,7 @@ class StreamingListenerTest : public Test { ...@@ -78,7 +78,7 @@ class StreamingListenerTest : public Test {
class FakeSocketWriter : public StreamingListener::AbstractSocketWriter { class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {
public: public:
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const std::string& message) { output_ += message; } void Send(const std::string& message) override { output_ += message; }
std::string output_; std::string output_;
}; };
...@@ -438,7 +438,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -438,7 +438,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
static const TimeInMillis kMillisPerSec = 1000; static const TimeInMillis kMillisPerSec = 1000;
private: private:
virtual void SetUp() { void SetUp() override {
saved_tz_ = nullptr; saved_tz_ = nullptr;
GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */)
...@@ -452,7 +452,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -452,7 +452,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
SetTimeZone("UTC+00"); SetTimeZone("UTC+00");
} }
virtual void TearDown() { void TearDown() override {
SetTimeZone(saved_tz_); SetTimeZone(saved_tz_);
free(const_cast<char*>(saved_tz_)); free(const_cast<char*>(saved_tz_));
saved_tz_ = nullptr; saved_tz_ = nullptr;
...@@ -1361,7 +1361,7 @@ class TestResultTest : public Test { ...@@ -1361,7 +1361,7 @@ class TestResultTest : public Test {
// ... and 3 TestResult objects. // ... and 3 TestResult objects.
TestResult * r0, * r1, * r2; TestResult * r0, * r1, * r2;
virtual void SetUp() { void SetUp() override {
// pr1 is for success. // pr1 is for success.
pr1 = new TestPartResult(TestPartResult::kSuccess, pr1 = new TestPartResult(TestPartResult::kSuccess,
"foo/bar.cc", "foo/bar.cc",
...@@ -1398,7 +1398,7 @@ class TestResultTest : public Test { ...@@ -1398,7 +1398,7 @@ class TestResultTest : public Test {
results2->push_back(*pr2); results2->push_back(*pr2);
} }
virtual void TearDown() { void TearDown() override {
delete pr1; delete pr1;
delete pr2; delete pr2;
...@@ -1826,12 +1826,12 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) { ...@@ -1826,12 +1826,12 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) {
class ShouldShardTest : public testing::Test { class ShouldShardTest : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
index_var_ = GTEST_FLAG_PREFIX_UPPER_ "INDEX"; index_var_ = GTEST_FLAG_PREFIX_UPPER_ "INDEX";
total_var_ = GTEST_FLAG_PREFIX_UPPER_ "TOTAL"; total_var_ = GTEST_FLAG_PREFIX_UPPER_ "TOTAL";
} }
virtual void TearDown() { void TearDown() override {
SetEnv(index_var_, ""); SetEnv(index_var_, "");
SetEnv(total_var_, ""); SetEnv(total_var_, "");
} }
...@@ -2094,7 +2094,7 @@ TEST_F(UnitTestRecordPropertyTest, ...@@ -2094,7 +2094,7 @@ TEST_F(UnitTestRecordPropertyTest,
class UnitTestRecordPropertyTestEnvironment : public Environment { class UnitTestRecordPropertyTestEnvironment : public Environment {
public: public:
virtual void TearDown() { void TearDown() override {
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
"tests"); "tests");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
...@@ -2707,7 +2707,7 @@ class FloatingPointTest : public Test { ...@@ -2707,7 +2707,7 @@ class FloatingPointTest : public Test {
typedef typename testing::internal::FloatingPoint<RawType> Floating; typedef typename testing::internal::FloatingPoint<RawType> Floating;
typedef typename Floating::Bits Bits; typedef typename Floating::Bits Bits;
virtual void SetUp() { void SetUp() override {
const size_t max_ulps = Floating::kMaxUlps; const size_t max_ulps = Floating::kMaxUlps;
// The bits that represent 0.0. // The bits that represent 0.0.
...@@ -5061,7 +5061,7 @@ class TestLifeCycleTest : public Test { ...@@ -5061,7 +5061,7 @@ class TestLifeCycleTest : public Test {
// Destructor. Decrements the number of test objects that uses this // Destructor. Decrements the number of test objects that uses this
// fixture. // fixture.
~TestLifeCycleTest() { count_--; } ~TestLifeCycleTest() override { count_--; }
// Returns the number of live test objects that uses this fixture. // Returns the number of live test objects that uses this fixture.
int count() const { return count_; } int count() const { return count_; }
...@@ -5448,7 +5448,7 @@ class SetUpTestCaseTest : public Test { ...@@ -5448,7 +5448,7 @@ class SetUpTestCaseTest : public Test {
} }
// This will be called before each test in this test case. // This will be called before each test in this test case.
virtual void SetUp() { void SetUp() override {
// SetUpTestCase() should be called only once, so counter_ should // SetUpTestCase() should be called only once, so counter_ should
// always be 1. // always be 1.
EXPECT_EQ(1, counter_); EXPECT_EQ(1, counter_);
...@@ -5628,7 +5628,7 @@ struct Flags { ...@@ -5628,7 +5628,7 @@ struct Flags {
class ParseFlagsTest : public Test { class ParseFlagsTest : public Test {
protected: protected:
// Clears the flags before each test. // Clears the flags before each test.
virtual void SetUp() { void SetUp() override {
GTEST_FLAG(also_run_disabled_tests) = false; GTEST_FLAG(also_run_disabled_tests) = false;
GTEST_FLAG(break_on_failure) = false; GTEST_FLAG(break_on_failure) = false;
GTEST_FLAG(catch_exceptions) = false; GTEST_FLAG(catch_exceptions) = false;
...@@ -6181,16 +6181,9 @@ TEST_F(FlagfileTest, Empty) { ...@@ -6181,16 +6181,9 @@ TEST_F(FlagfileTest, Empty) {
std::string flagfile_flag = std::string flagfile_flag =
std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str();
const char* argv[] = { const char* argv[] = {"foo.exe", flagfile_flag.c_str(), nullptr};
"foo.exe",
flagfile_flag.c_str(),
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);
} }
...@@ -6202,16 +6195,9 @@ TEST_F(FlagfileTest, FilterNonEmpty) { ...@@ -6202,16 +6195,9 @@ TEST_F(FlagfileTest, FilterNonEmpty) {
std::string flagfile_flag = std::string flagfile_flag =
std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str();
const char* argv[] = { const char* argv[] = {"foo.exe", flagfile_flag.c_str(), nullptr};
"foo.exe",
flagfile_flag.c_str(),
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false);
} }
...@@ -6225,16 +6211,9 @@ TEST_F(FlagfileTest, SeveralFlags) { ...@@ -6225,16 +6211,9 @@ TEST_F(FlagfileTest, SeveralFlags) {
std::string flagfile_flag = std::string flagfile_flag =
std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str();
const char* argv[] = { const char* argv[] = {"foo.exe", flagfile_flag.c_str(), nullptr};
"foo.exe",
flagfile_flag.c_str(),
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
Flags expected_flags; Flags expected_flags;
expected_flags.break_on_failure = true; expected_flags.break_on_failure = true;
...@@ -6337,12 +6316,8 @@ TEST(NestedTestingNamespaceTest, Failure) { ...@@ -6337,12 +6316,8 @@ TEST(NestedTestingNamespaceTest, Failure) {
// successfully. // successfully.
class ProtectedFixtureMethodsTest : public Test { class ProtectedFixtureMethodsTest : public Test {
protected: protected:
virtual void SetUp() { void SetUp() override { Test::SetUp(); }
Test::SetUp(); void TearDown() override { Test::TearDown(); }
}
virtual void TearDown() {
Test::TearDown();
}
}; };
// StreamingAssertionsTest tests the streaming versions of a representative // StreamingAssertionsTest tests the streaming versions of a representative
...@@ -6720,13 +6695,13 @@ class TestListener : public EmptyTestEventListener { ...@@ -6720,13 +6695,13 @@ class TestListener : public EmptyTestEventListener {
: on_start_counter_(on_start_counter), : on_start_counter_(on_start_counter),
is_destroyed_(is_destroyed) {} is_destroyed_(is_destroyed) {}
virtual ~TestListener() { ~TestListener() override {
if (is_destroyed_) if (is_destroyed_)
*is_destroyed_ = true; *is_destroyed_ = true;
} }
protected: protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
if (on_start_counter_ != nullptr) (*on_start_counter_)++; if (on_start_counter_ != nullptr) (*on_start_counter_)++;
} }
...@@ -6795,21 +6770,21 @@ class SequenceTestingListener : public EmptyTestEventListener { ...@@ -6795,21 +6770,21 @@ class SequenceTestingListener : public EmptyTestEventListener {
: vector_(vector), id_(id) {} : vector_(vector), id_(id) {}
protected: protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
vector_->push_back(GetEventDescription("OnTestProgramStart")); vector_->push_back(GetEventDescription("OnTestProgramStart"));
} }
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) { void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {
vector_->push_back(GetEventDescription("OnTestProgramEnd")); vector_->push_back(GetEventDescription("OnTestProgramEnd"));
} }
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/, void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) { int /*iteration*/) override {
vector_->push_back(GetEventDescription("OnTestIterationStart")); vector_->push_back(GetEventDescription("OnTestIterationStart"));
} }
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) { int /*iteration*/) override {
vector_->push_back(GetEventDescription("OnTestIterationEnd")); vector_->push_back(GetEventDescription("OnTestIterationEnd"));
} }
...@@ -7298,9 +7273,6 @@ TEST(IsHashTable, Basic) { ...@@ -7298,9 +7273,6 @@ TEST(IsHashTable, Basic) {
EXPECT_FALSE(testing::internal::IsHashTable<NotReallyAHashTable>::value); EXPECT_FALSE(testing::internal::IsHashTable<NotReallyAHashTable>::value);
EXPECT_FALSE(testing::internal::IsHashTable<std::vector<int>>::value); EXPECT_FALSE(testing::internal::IsHashTable<std::vector<int>>::value);
EXPECT_TRUE(testing::internal::IsHashTable<std::unordered_set<int>>::value); EXPECT_TRUE(testing::internal::IsHashTable<std::unordered_set<int>>::value);
#if GTEST_HAS_HASH_SET_
EXPECT_TRUE(testing::internal::IsHashTable<__gnu_cxx::hash_set<int>>::value);
#endif // GTEST_HAS_HASH_SET_
} }
// Tests ArrayEq(). // Tests ArrayEq().
...@@ -7450,6 +7422,84 @@ TEST(NativeArrayTest, WorksForTwoDimensionalArray) { ...@@ -7450,6 +7422,84 @@ TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
EXPECT_EQ(a, na.begin()); EXPECT_EQ(a, na.begin());
} }
// IndexSequence
TEST(IndexSequence, MakeIndexSequence) {
using testing::internal::IndexSequence;
using testing::internal::MakeIndexSequence;
EXPECT_TRUE(
(std::is_same<IndexSequence<>, MakeIndexSequence<0>::type>::value));
EXPECT_TRUE(
(std::is_same<IndexSequence<0>, MakeIndexSequence<1>::type>::value));
EXPECT_TRUE(
(std::is_same<IndexSequence<0, 1>, MakeIndexSequence<2>::type>::value));
EXPECT_TRUE((
std::is_same<IndexSequence<0, 1, 2>, MakeIndexSequence<3>::type>::value));
EXPECT_TRUE(
(std::is_base_of<IndexSequence<0, 1, 2>, MakeIndexSequence<3>>::value));
}
// ElemFromList
TEST(ElemFromList, Basic) {
using testing::internal::ElemFromList;
using Idx = testing::internal::MakeIndexSequence<3>::type;
EXPECT_TRUE((
std::is_same<int, ElemFromList<0, Idx, int, double, char>::type>::value));
EXPECT_TRUE(
(std::is_same<double,
ElemFromList<1, Idx, int, double, char>::type>::value));
EXPECT_TRUE(
(std::is_same<char,
ElemFromList<2, Idx, int, double, char>::type>::value));
EXPECT_TRUE(
(std::is_same<
char, ElemFromList<7, testing::internal::MakeIndexSequence<12>::type,
int, int, int, int, int, int, int, char, int, int,
int, int>::type>::value));
}
// FlatTuple
TEST(FlatTuple, Basic) {
using testing::internal::FlatTuple;
FlatTuple<int, double, const char*> tuple = {};
EXPECT_EQ(0, tuple.Get<0>());
EXPECT_EQ(0.0, tuple.Get<1>());
EXPECT_EQ(nullptr, tuple.Get<2>());
tuple = FlatTuple<int, double, const char*>(7, 3.2, "Foo");
EXPECT_EQ(7, tuple.Get<0>());
EXPECT_EQ(3.2, tuple.Get<1>());
EXPECT_EQ(std::string("Foo"), tuple.Get<2>());
tuple.Get<1>() = 5.1;
EXPECT_EQ(5.1, tuple.Get<1>());
}
TEST(FlatTuple, ManyTypes) {
using testing::internal::FlatTuple;
// Instantiate FlatTuple with 257 ints.
// Tests show that we can do it with thousands of elements, but very long
// compile times makes it unusuitable for this test.
#define GTEST_FLAT_TUPLE_INT8 int, int, int, int, int, int, int, int,
#define GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT8 GTEST_FLAT_TUPLE_INT8
#define GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT16
#define GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT32
#define GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT64
#define GTEST_FLAT_TUPLE_INT256 GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT128
// Let's make sure that we can have a very long list of types without blowing
// up the template instantiation depth.
FlatTuple<GTEST_FLAT_TUPLE_INT256 int> tuple;
tuple.Get<0>() = 7;
tuple.Get<99>() = 17;
tuple.Get<256>() = 1000;
EXPECT_EQ(7, tuple.Get<0>());
EXPECT_EQ(17, tuple.Get<99>());
EXPECT_EQ(1000, tuple.Get<256>());
}
// Tests SkipPrefix(). // Tests SkipPrefix().
TEST(SkipPrefixTest, SkipsWhenPrefixMatches) { TEST(SkipPrefixTest, SkipsWhenPrefixMatches) {
...@@ -7497,3 +7547,30 @@ TEST_F(AdHocTestResultTest, AdHocTestResultTestForUnitTestDoesNotShowFailure) { ...@@ -7497,3 +7547,30 @@ TEST_F(AdHocTestResultTest, AdHocTestResultTestForUnitTestDoesNotShowFailure) {
testing::UnitTest::GetInstance()->ad_hoc_test_result(); testing::UnitTest::GetInstance()->ad_hoc_test_result();
EXPECT_FALSE(test_result.Failed()); EXPECT_FALSE(test_result.Failed());
} }
class DynamicUnitTestFixture : public testing::Test {};
class DynamicTest : public DynamicUnitTestFixture {
void TestBody() override { EXPECT_TRUE(true); }
};
auto* dynamic_test = testing::RegisterTest(
"DynamicUnitTestFixture", "DynamicTest", "TYPE", "VALUE", __FILE__,
__LINE__, []() -> DynamicUnitTestFixture* { return new DynamicTest; });
TEST(RegisterTest, WasRegistered) {
auto* unittest = testing::UnitTest::GetInstance();
for (int i = 0; i < unittest->total_test_case_count(); ++i) {
auto* tests = unittest->GetTestCase(i);
if (tests->name() != std::string("DynamicUnitTestFixture")) continue;
for (int j = 0; j < tests->total_test_count(); ++j) {
if (tests->GetTestInfo(j)->name() != std::string("DynamicTest")) continue;
// Found it.
EXPECT_STREQ(tests->GetTestInfo(j)->value_param(), "VALUE");
EXPECT_STREQ(tests->GetTestInfo(j)->type_param(), "TYPE");
return;
}
}
FAIL() << "Didn't find the test!";
}
...@@ -34,12 +34,8 @@ ...@@ -34,12 +34,8 @@
class PropertyOne : public testing::Test { class PropertyOne : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override { RecordProperty("SetUpProp", 1); }
RecordProperty("SetUpProp", 1); void TearDown() override { RecordProperty("TearDownProp", 1); }
}
virtual void TearDown() {
RecordProperty("TearDownProp", 1);
}
}; };
TEST_F(PropertyOne, TestSomeProperties) { TEST_F(PropertyOne, TestSomeProperties) {
......
...@@ -34,12 +34,8 @@ ...@@ -34,12 +34,8 @@
class PropertyTwo : public testing::Test { class PropertyTwo : public testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override { RecordProperty("SetUpProp", 2); }
RecordProperty("SetUpProp", 2); void TearDown() override { RecordProperty("TearDownProp", 2); }
}
virtual void TearDown() {
RecordProperty("TearDownProp", 2);
}
}; };
TEST_F(PropertyTwo, TestSomeProperties) { TEST_F(PropertyTwo, TestSomeProperties) {
......
...@@ -65,7 +65,7 @@ else: ...@@ -65,7 +65,7 @@ else:
sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG) sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42"> <testsuites tests="24" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/> <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
...@@ -108,6 +108,9 @@ Invalid characters in brackets []%(stack)s]]></failure> ...@@ -108,6 +108,9 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="DisabledTest" tests="1" failures="0" disabled="1" errors="0" time="*"> <testsuite name="DisabledTest" tests="1" failures="0" disabled="1" errors="0" time="*">
<testcase name="DISABLED_test_not_run" status="notrun" time="*" classname="DisabledTest"/> <testcase name="DISABLED_test_not_run" status="notrun" time="*" classname="DisabledTest"/>
</testsuite> </testsuite>
<testsuite name="SkippedTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Skipped" status="skipped" time="*" classname="SkippedTest"/>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye"> <testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest"> <testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest">
<properties> <properties>
...@@ -183,15 +186,15 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -183,15 +186,15 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/> <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
<testsuite name="NoFixtureTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye">
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest"> <testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key" value="1"/> <property name="key_1" value="2"/>
</properties> </properties>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="AnotherTestThatHasValueParamAttribute/1" value_param="42" status="run" time="*" classname="Single/ValueParamTest" /> <testcase name="AnotherTestThatHasValueParamAttribute/0" value_param="33" status="run" time="*" classname="Single/ValueParamTest" />
</testsuite> </testsuite>
</testsuites>""" </testsuites>"""
...@@ -266,7 +269,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -266,7 +269,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'gtest_no_test_unittest') 'gtest_no_test_unittest')
try: try:
os.remove(output_file) os.remove(output_file)
except OSError, e: except OSError:
e = sys.exc_info()[1]
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
......
...@@ -67,6 +67,13 @@ TEST_F(DisabledTest, DISABLED_test_not_run) { ...@@ -67,6 +67,13 @@ TEST_F(DisabledTest, DISABLED_test_not_run) {
FAIL() << "Unexpected failure: Disabled test should not be run"; FAIL() << "Unexpected failure: Disabled test should not be run";
} }
class SkippedTest : public Test {
};
TEST_F(SkippedTest, Skipped) {
GTEST_SKIP();
}
TEST(MixedResultTest, Succeeds) { TEST(MixedResultTest, Succeeds) {
EXPECT_EQ(1, 1); EXPECT_EQ(1, 1);
ASSERT_EQ(1, 1); ASSERT_EQ(1, 1);
......
...@@ -94,7 +94,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): ...@@ -94,7 +94,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self.assertEquals( self.assertEquals(
len(expected_children), len(actual_children), len(expected_children), len(actual_children),
'number of child elements differ in element ' + actual_node.tagName) 'number of child elements differ in element ' + actual_node.tagName)
for child_id, child in expected_children.iteritems(): for child_id, child in expected_children.items():
self.assert_(child_id in actual_children, self.assert_(child_id in actual_children,
'<%s> is not in <%s> (in element %s)' % '<%s> is not in <%s> (in element %s)' %
(child_id, actual_children, actual_node.tagName)) (child_id, actual_children, actual_node.tagName))
......
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