aboutsummaryrefslogtreecommitdiffstats
path: root/gtest/include
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-05-29 13:00:38 -0700
committerWink Saville <wink@google.com>2010-05-29 13:00:38 -0700
commitd0332953cda33fb4f8e24ebff9c49159b69c43d6 (patch)
tree81612e8b12f590310aeb0ebf1da37b304eb7baa6 /gtest/include
parentede38fe9b9f93888e6e41afc7abb09525f44da95 (diff)
downloadexternal_protobuf-d0332953cda33fb4f8e24ebff9c49159b69c43d6.zip
external_protobuf-d0332953cda33fb4f8e24ebff9c49159b69c43d6.tar.gz
external_protobuf-d0332953cda33fb4f8e24ebff9c49159b69c43d6.tar.bz2
Add protobuf 2.3.0 sources
This is the contents of protobuf-2.3.0.tar.bz2 from http://code.google.com/p/protobuf/downloads/list. Change-Id: Idfde09ce7ef5ac027b07ee83f2674fbbed5c30b2
Diffstat (limited to 'gtest/include')
-rw-r--r--gtest/include/gtest/gtest-death-test.h17
-rw-r--r--gtest/include/gtest/gtest-spi.h39
-rw-r--r--gtest/include/gtest/gtest-test-part.h30
-rw-r--r--gtest/include/gtest/gtest.h333
-rw-r--r--gtest/include/gtest/internal/gtest-death-test-internal.h51
-rw-r--r--gtest/include/gtest/internal/gtest-internal.h53
-rw-r--r--gtest/include/gtest/internal/gtest-param-util-generated.h285
-rw-r--r--gtest/include/gtest/internal/gtest-param-util-generated.h.pump21
-rw-r--r--gtest/include/gtest/internal/gtest-param-util.h11
-rw-r--r--gtest/include/gtest/internal/gtest-port.h114
-rw-r--r--gtest/include/gtest/internal/gtest-string.h135
11 files changed, 809 insertions, 280 deletions
diff --git a/gtest/include/gtest/gtest-death-test.h b/gtest/include/gtest/gtest-death-test.h
index 410654b..fdb497f 100644
--- a/gtest/include/gtest/gtest-death-test.h
+++ b/gtest/include/gtest/gtest-death-test.h
@@ -181,6 +181,9 @@ class ExitedWithCode {
explicit ExitedWithCode(int exit_code);
bool operator()(int exit_status) const;
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ExitedWithCode& other);
+
const int exit_code_;
};
@@ -242,10 +245,10 @@ class KilledBySignal {
#ifdef NDEBUG
#define EXPECT_DEBUG_DEATH(statement, regex) \
- do { statement; } while (false)
+ do { statement; } while (::testing::internal::AlwaysFalse())
#define ASSERT_DEBUG_DEATH(statement, regex) \
- do { statement; } while (false)
+ do { statement; } while (::testing::internal::AlwaysFalse())
#else
@@ -260,7 +263,7 @@ class KilledBySignal {
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
-// death tests are supported; otherwise they expand to empty. This is
+// death tests are supported; otherwise they just issue a warning. This is
// useful when you are combining death test assertions with normal test
// assertions in one test.
#if GTEST_HAS_DEATH_TEST
@@ -270,13 +273,9 @@ class KilledBySignal {
ASSERT_DEATH(statement, regex)
#else
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
- GTEST_LOG_(WARNING, \
- "Death tests are not supported on this platform. The statement" \
- " '" #statement "' can not be verified")
+ GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
- GTEST_LOG_(WARNING, \
- "Death tests are not supported on this platform. The statement" \
- " '" #statement "' can not be verified")
+ GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
#endif
} // namespace testing
diff --git a/gtest/include/gtest/gtest-spi.h b/gtest/include/gtest/gtest-spi.h
index a4e387a..2953411 100644
--- a/gtest/include/gtest/gtest-spi.h
+++ b/gtest/include/gtest/gtest-spi.h
@@ -97,12 +97,12 @@ class SingleFailureChecker {
public:
// The constructor remembers the arguments.
SingleFailureChecker(const TestPartResultArray* results,
- TestPartResultType type,
+ TestPartResult::Type type,
const char* substr);
~SingleFailureChecker();
private:
const TestPartResultArray* const results_;
- const TestPartResultType type_;
+ const TestPartResult::Type type_;
const String substr_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
@@ -143,14 +143,14 @@ class SingleFailureChecker {
};\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
- &gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
+ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do { \
@@ -160,14 +160,14 @@ class SingleFailureChecker {
};\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
- &gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
+ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ALL_THREADS, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
// A macro for testing Google Test assertions or code that's expected to
// generate Google Test non-fatal failures. It asserts that the given
@@ -190,32 +190,43 @@ class SingleFailureChecker {
// Note that even though the implementations of the following two
// macros are much alike, we cannot refactor them to use a common
// helper macro, due to some peculiarity in how the preprocessor
-// works. The AcceptsMacroThatExpandsToUnprotectedComma test in
-// gtest_unittest.cc will fail to compile if we do that.
+// works. If we do that, the code won't compile when the user gives
+// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
+// expands to code containing an unprotected comma. The
+// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
+// catches that.
+//
+// For the same reason, we have to write
+// if (::testing::internal::AlwaysTrue()) { statement; }
+// instead of
+// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
+// to avoid an MSVC warning on unreachable code.
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
do {\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
- &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
+ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
+ (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
- statement;\
+ if (::testing::internal::AlwaysTrue()) { statement; }\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do {\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
- &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
+ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
+ (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
&gtest_failures);\
- statement;\
+ if (::testing::internal::AlwaysTrue()) { statement; }\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
diff --git a/gtest/include/gtest/gtest-test-part.h b/gtest/include/gtest/gtest-test-part.h
index d5b2713..58e7df9 100644
--- a/gtest/include/gtest/gtest-test-part.h
+++ b/gtest/include/gtest/gtest-test-part.h
@@ -39,24 +39,24 @@
namespace testing {
-// The possible outcomes of a test part (i.e. an assertion or an
-// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
-enum TestPartResultType {
- TPRT_SUCCESS, // Succeeded.
- TPRT_NONFATAL_FAILURE, // Failed but the test can continue.
- TPRT_FATAL_FAILURE // Failed and the test should be terminated.
-};
-
// A copyable object representing the result of a test part (i.e. an
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
//
// Don't inherit from TestPartResult as its destructor is not virtual.
class TestPartResult {
public:
+ // The possible outcomes of a test part (i.e. an assertion or an
+ // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
+ enum Type {
+ kSuccess, // Succeeded.
+ kNonFatalFailure, // Failed but the test can continue.
+ kFatalFailure // Failed and the test should be terminated.
+ };
+
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestPartResult object.
- TestPartResult(TestPartResultType type,
+ TestPartResult(Type type,
const char* file_name,
int line_number,
const char* message)
@@ -68,7 +68,7 @@ class TestPartResult {
}
// Gets the outcome of the test part.
- TestPartResultType type() const { return type_; }
+ Type type() const { return type_; }
// Gets the name of the source file where the test part took place, or
// NULL if it's unknown.
@@ -85,18 +85,18 @@ class TestPartResult {
const char* message() const { return message_.c_str(); }
// Returns true iff the test part passed.
- bool passed() const { return type_ == TPRT_SUCCESS; }
+ bool passed() const { return type_ == kSuccess; }
// Returns true iff the test part failed.
- bool failed() const { return type_ != TPRT_SUCCESS; }
+ bool failed() const { return type_ != kSuccess; }
// Returns true iff the test part non-fatally failed.
- bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; }
+ bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
// Returns true iff the test part fatally failed.
- bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; }
+ bool fatally_failed() const { return type_ == kFatalFailure; }
private:
- TestPartResultType type_;
+ Type type_;
// Gets the summary of the failure message by omitting the stack
// trace in it.
diff --git a/gtest/include/gtest/gtest.h b/gtest/include/gtest/gtest.h
index 90c36a5..9be15fb 100644
--- a/gtest/include/gtest/gtest.h
+++ b/gtest/include/gtest/gtest.h
@@ -51,9 +51,6 @@
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_H_
-// The following platform macro is used throughout Google Test:
-// _WIN32_WCE Windows CE (set in project files)
-
#include <limits>
#include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-string.h>
@@ -130,7 +127,7 @@ GTEST_DECLARE_int32_(repeat);
// stack frames in failure stack traces.
GTEST_DECLARE_bool_(show_internal_stack_frames);
-// When this flag is specified, tests' order is randomized on every run.
+// When this flag is specified, tests' order is randomized on every iteration.
GTEST_DECLARE_bool_(shuffle);
// This flag specifies the maximum number of stack frames to be
@@ -150,16 +147,19 @@ namespace internal {
class AssertHelper;
class DefaultGlobalTestPartResultReporter;
class ExecDeathTest;
+class NoExecDeathTest;
class FinalSuccessChecker;
class GTestFlagSaver;
-class TestCase;
class TestInfoImpl;
class TestResultAccessor;
-class UnitTestAccessor;
+class TestEventListenersAccessor;
+class TestEventRepeater;
class WindowsDeathTest;
class UnitTestImpl* GetUnitTestImpl();
-void ReportFailureInUnknownLocation(TestPartResultType result_type,
+void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const String& message);
+class PrettyUnitTestResultPrinter;
+class XmlUnitTestResultPrinter;
// Converts a streamable value to a String. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
@@ -366,8 +366,6 @@ class Test {
typedef internal::TimeInMillis TimeInMillis;
-namespace internal {
-
// A copyable object representing a user specified test property which can be
// output as a key/value string pair.
//
@@ -450,14 +448,14 @@ class TestResult {
const TestProperty& GetTestProperty(int i) const;
private:
+ friend class TestInfo;
+ friend class UnitTest;
friend class internal::DefaultGlobalTestPartResultReporter;
friend class internal::ExecDeathTest;
friend class internal::TestInfoImpl;
friend class internal::TestResultAccessor;
friend class internal::UnitTestImpl;
friend class internal::WindowsDeathTest;
- friend class testing::TestInfo;
- friend class testing::UnitTest;
// Gets the vector of TestPartResults.
const internal::Vector<TestPartResult>& test_part_results() const {
@@ -516,8 +514,6 @@ class TestResult {
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
}; // class TestResult
-} // namespace internal
-
// A TestInfo object stores the following information about a test:
//
// Test case name
@@ -566,16 +562,16 @@ class TestInfo {
bool should_run() const;
// Returns the result of the test.
- const internal::TestResult* result() const;
+ const TestResult* result() const;
private:
#if GTEST_HAS_DEATH_TEST
friend class internal::DefaultDeathTestFactory;
#endif // GTEST_HAS_DEATH_TEST
+ friend class Test;
+ friend class TestCase;
friend class internal::TestInfoImpl;
friend class internal::UnitTestImpl;
- friend class Test;
- friend class internal::TestCase;
friend TestInfo* internal::MakeAndRegisterTestInfo(
const char* test_case_name, const char* name,
const char* test_case_comment, const char* comment,
@@ -608,8 +604,6 @@ class TestInfo {
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
};
-namespace internal {
-
// A test case, which consists of a vector of TestInfos.
//
// TestCase is not copyable.
@@ -670,7 +664,7 @@ class TestCase {
const TestInfo* GetTestInfo(int i) const;
private:
- friend class testing::Test;
+ friend class Test;
friend class internal::UnitTestImpl;
// Gets the (mutable) vector of TestInfos in this TestCase.
@@ -681,6 +675,10 @@ class TestCase {
return *test_info_list_;
}
+ // Returns the i-th test among all the tests. i can range from 0 to
+ // total_test_count() - 1. If i is not in that range, returns NULL.
+ TestInfo* GetMutableTestInfo(int i);
+
// Sets the should_run member.
void set_should_run(bool should) { should_run_ = should; }
@@ -699,9 +697,6 @@ class TestCase {
// Runs every test in this TestCase.
void Run();
- // Runs every test in the given TestCase.
- static void RunTestCase(TestCase * test_case) { test_case->Run(); }
-
// Returns true iff test passed.
static bool TestPassed(const TestInfo * test_info);
@@ -714,12 +709,23 @@ class TestCase {
// Returns true if the given test should run.
static bool ShouldRunTest(const TestInfo *test_info);
+ // Shuffles the tests in this test case.
+ void ShuffleTests(internal::Random* random);
+
+ // Restores the test order to before the first shuffle.
+ void UnshuffleTests();
+
// Name of the test case.
internal::String name_;
// Comment on the test case.
internal::String comment_;
- // Vector of TestInfos.
- internal::Vector<TestInfo*>* test_info_list_;
+ // The vector of TestInfos in their original order. It owns the
+ // elements in the vector.
+ const internal::scoped_ptr<internal::Vector<TestInfo*> > test_info_list_;
+ // Provides a level of indirection for the test list to allow easy
+ // shuffling and restoring the test order. The i-th element in this
+ // vector is the index of the i-th test in the shuffled test list.
+ const internal::scoped_ptr<internal::Vector<int> > test_indices_;
// Pointer to the function that sets up the test case.
Test::SetUpTestCaseFunc set_up_tc_;
// Pointer to the function that tears down the test case.
@@ -733,8 +739,6 @@ class TestCase {
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
};
-} // namespace internal
-
// An Environment object is capable of setting up and tearing down an
// environment. The user should subclass this to define his own
// environment(s).
@@ -766,6 +770,158 @@ class Environment {
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
};
+// The interface for tracing execution of tests. The methods are organized in
+// the order the corresponding events are fired.
+class TestEventListener {
+ public:
+ virtual ~TestEventListener() {}
+
+ // Fired before any test activity starts.
+ virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
+
+ // Fired before each iteration of tests starts. There may be more than
+ // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
+ // index, starting from 0.
+ virtual void OnTestIterationStart(const UnitTest& unit_test,
+ int iteration) = 0;
+
+ // Fired before environment set-up for each iteration of tests starts.
+ virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
+
+ // Fired after environment set-up for each iteration of tests ends.
+ virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
+
+ // Fired before the test case starts.
+ virtual void OnTestCaseStart(const TestCase& test_case) = 0;
+
+ // Fired before the test starts.
+ virtual void OnTestStart(const TestInfo& test_info) = 0;
+
+ // Fired after a failed assertion or a SUCCESS().
+ virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
+
+ // Fired after the test ends.
+ virtual void OnTestEnd(const TestInfo& test_info) = 0;
+
+ // Fired after the test case ends.
+ virtual void OnTestCaseEnd(const TestCase& test_case) = 0;
+
+ // Fired before environment tear-down for each iteration of tests starts.
+ virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
+
+ // Fired after environment tear-down for each iteration of tests ends.
+ virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
+
+ // Fired after each iteration of tests finishes.
+ virtual void OnTestIterationEnd(const UnitTest& unit_test,
+ int iteration) = 0;
+
+ // Fired after all test activities have ended.
+ virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
+};
+
+// The convenience class for users who need to override just one or two
+// methods and are not concerned that a possible change to a signature of
+// the methods they override will not be caught during the build. For
+// comments about each method please see the definition of TestEventListener
+// above.
+class EmptyTestEventListener : public TestEventListener {
+ public:
+ virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
+ virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
+ int /*iteration*/) {}
+ virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
+ virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
+ virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
+ virtual void OnTestStart(const TestInfo& /*test_info*/) {}
+ virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}
+ virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
+ virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
+ virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}
+ virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
+ virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
+ int /*iteration*/) {}
+ virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
+};
+
+// TestEventListeners lets users add listeners to track events in Google Test.
+class TestEventListeners {
+ public:
+ TestEventListeners();
+ ~TestEventListeners();
+
+ // Appends an event listener to the end of the list. Google Test assumes
+ // the ownership of the listener (i.e. it will delete the listener when
+ // the test program finishes).
+ void Append(TestEventListener* listener);
+
+ // Removes the given event listener from the list and returns it. It then
+ // becomes the caller's responsibility to delete the listener. Returns
+ // NULL if the listener is not found in the list.
+ TestEventListener* Release(TestEventListener* listener);
+
+ // Returns the standard listener responsible for the default console
+ // output. Can be removed from the listeners list to shut down default
+ // console output. Note that removing this object from the listener list
+ // with Release transfers its ownership to the caller and makes this
+ // function return NULL the next time.
+ TestEventListener* default_result_printer() const {
+ return default_result_printer_;
+ }
+
+ // Returns the standard listener responsible for the default XML output
+ // controlled by the --gtest_output=xml flag. Can be removed from the
+ // listeners list by users who want to shut down the default XML output
+ // controlled by this flag and substitute it with custom one. Note that
+ // removing this object from the listener list with Release transfers its
+ // ownership to the caller and makes this function return NULL the next
+ // time.
+ TestEventListener* default_xml_generator() const {
+ return default_xml_generator_;
+ }
+
+ private:
+ friend class TestCase;
+ friend class internal::DefaultGlobalTestPartResultReporter;
+ friend class internal::NoExecDeathTest;
+ friend class internal::TestEventListenersAccessor;
+ friend class internal::TestInfoImpl;
+ friend class internal::UnitTestImpl;
+
+ // Returns repeater that broadcasts the TestEventListener events to all
+ // subscribers.
+ TestEventListener* repeater();
+
+ // Sets the default_result_printer attribute to the provided listener.
+ // The listener is also added to the listener list and previous
+ // default_result_printer is removed from it and deleted. The listener can
+ // also be NULL in which case it will not be added to the list. Does
+ // nothing if the previous and the current listener objects are the same.
+ void SetDefaultResultPrinter(TestEventListener* listener);
+
+ // Sets the default_xml_generator attribute to the provided listener. The
+ // listener is also added to the listener list and previous
+ // default_xml_generator is removed from it and deleted. The listener can
+ // also be NULL in which case it will not be added to the list. Does
+ // nothing if the previous and the current listener objects are the same.
+ void SetDefaultXmlGenerator(TestEventListener* listener);
+
+ // Controls whether events will be forwarded by the repeater to the
+ // listeners in the list.
+ bool EventForwardingEnabled() const;
+ void SuppressEventForwarding();
+
+ // The actual list of listeners.
+ internal::TestEventRepeater* repeater_;
+ // Listener responsible for the standard result output.
+ TestEventListener* default_result_printer_;
+ // Listener responsible for the creation of the XML output file.
+ TestEventListener* default_xml_generator_;
+
+ // We disallow copying TestEventListeners.
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
+};
+
// A UnitTest consists of a vector of TestCases.
//
// This is a singleton class. The only instance of UnitTest is
@@ -797,7 +953,7 @@ class UnitTest {
// Returns the TestCase object for the test that's currently running,
// or NULL if no test is running.
- const internal::TestCase* current_test_case() const;
+ const TestCase* current_test_case() const;
// Returns the TestInfo object for the test that's currently running,
// or NULL if no test is running.
@@ -814,36 +970,6 @@ class UnitTest {
internal::ParameterizedTestCaseRegistry& parameterized_test_registry();
#endif // GTEST_HAS_PARAM_TEST
- private:
- // Registers and returns a global test environment. When a test
- // program is run, all global test environments will be set-up in
- // the order they were registered. After all tests in the program
- // have finished, all global test environments will be torn-down in
- // the *reverse* order they were registered.
- //
- // The UnitTest object takes ownership of the given environment.
- //
- // This method can only be called from the main thread.
- Environment* AddEnvironment(Environment* env);
-
- // Adds a TestPartResult to the current TestResult object. All
- // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
- // eventually call this to report their results. The user code
- // should use the assertion macros instead of calling this directly.
- void AddTestPartResult(TestPartResultType result_type,
- const char* file_name,
- int line_number,
- const internal::String& message,
- const internal::String& os_stack_trace);
-
- // Adds a TestProperty to the current TestResult object. If the result already
- // contains a property with the same key, the value will be updated.
- void RecordPropertyForCurrentTest(const char* key, const char* value);
-
- // Accessors for the implementation object.
- internal::UnitTestImpl* impl() { return impl_; }
- const internal::UnitTestImpl* impl() const { return impl_; }
-
// Gets the number of successful test cases.
int successful_test_case_count() const;
@@ -884,29 +1010,56 @@ class UnitTest {
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
- const internal::TestCase* GetTestCase(int i) const;
+ const TestCase* GetTestCase(int i) const;
- // ScopedTrace is a friend as it needs to modify the per-thread
- // trace stack, which is a private member of UnitTest.
- // TODO(vladl@google.com): Order all declarations according to the style
- // guide after publishing of the above methods is done.
+ // Returns the list of event listeners that can be used to track events
+ // inside Google Test.
+ TestEventListeners& listeners();
+
+ private:
+ // Registers and returns a global test environment. When a test
+ // program is run, all global test environments will be set-up in
+ // the order they were registered. After all tests in the program
+ // have finished, all global test environments will be torn-down in
+ // the *reverse* order they were registered.
+ //
+ // The UnitTest object takes ownership of the given environment.
+ //
+ // This method can only be called from the main thread.
+ Environment* AddEnvironment(Environment* env);
+
+ // Adds a TestPartResult to the current TestResult object. All
+ // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
+ // eventually call this to report their results. The user code
+ // should use the assertion macros instead of calling this directly.
+ void AddTestPartResult(TestPartResult::Type result_type,
+ const char* file_name,
+ int line_number,
+ const internal::String& message,
+ const internal::String& os_stack_trace);
+
+ // Adds a TestProperty to the current TestResult object. If the result already
+ // contains a property with the same key, the value will be updated.
+ void RecordPropertyForCurrentTest(const char* key, const char* value);
+
+ // Gets the i-th test case among all the test cases. i can range from 0 to
+ // total_test_case_count() - 1. If i is not in that range, returns NULL.
+ TestCase* GetMutableTestCase(int i);
+
+ // Accessors for the implementation object.
+ internal::UnitTestImpl* impl() { return impl_; }
+ const internal::UnitTestImpl* impl() const { return impl_; }
+
+ // These classes and funcions are friends as they need to access private
+ // members of UnitTest.
+ friend class Test;
+ friend class internal::AssertHelper;
friend class internal::ScopedTrace;
friend Environment* AddGlobalTestEnvironment(Environment* env);
friend internal::UnitTestImpl* internal::GetUnitTestImpl();
- friend class internal::AssertHelper;
- friend class Test;
friend void internal::ReportFailureInUnknownLocation(
- TestPartResultType result_type,
+ TestPartResult::Type result_type,
const internal::String& message);
- // TODO(vladl@google.com): Remove these when publishing the new accessors.
- friend class PrettyUnitTestResultPrinter;
- friend class XmlUnitTestResultPrinter;
- friend class internal::UnitTestAccessor;
- friend class FinalSuccessChecker;
- FRIEND_TEST(ApiTest, UnitTestImmutableAccessorsWork);
- FRIEND_TEST(ApiTest, TestCaseImmutableAccessorsWork);
- FRIEND_TEST(ApiTest, DisabledTestCaseAccessorsWork);
-
// Creates an empty UnitTest.
UnitTest();
@@ -1297,16 +1450,38 @@ AssertionResult DoubleNearPredFormat(const char* expr1,
class AssertHelper {
public:
// Constructor.
- AssertHelper(TestPartResultType type, const char* file, int line,
+ AssertHelper(TestPartResult::Type type,
+ const char* file,
+ int line,
const char* message);
+ ~AssertHelper();
+
// Message assignment is a semantic trick to enable assertion
// streaming; see the GTEST_MESSAGE_ macro below.
void operator=(const Message& message) const;
+
private:
- TestPartResultType const type_;
- const char* const file_;
- int const line_;
- String const message_;
+ // We put our data in a struct so that the size of the AssertHelper class can
+ // be as small as possible. This is important because gcc is incapable of
+ // re-using stack space even for temporary variables, so every EXPECT_EQ
+ // reserves stack space for another AssertHelper.
+ struct AssertHelperData {
+ AssertHelperData(TestPartResult::Type t,
+ const char* srcfile,
+ int line_num,
+ const char* msg)
+ : type(t), file(srcfile), line(line_num), message(msg) { }
+
+ TestPartResult::Type const type;
+ const char* const file;
+ int const line;
+ String const message;
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
+ };
+
+ AssertHelperData* const data_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
};
diff --git a/gtest/include/gtest/internal/gtest-death-test-internal.h b/gtest/include/gtest/internal/gtest-death-test-internal.h
index 143e58a..5aba1a0 100644
--- a/gtest/include/gtest/internal/gtest-death-test-internal.h
+++ b/gtest/include/gtest/internal/gtest-death-test-internal.h
@@ -153,7 +153,7 @@ bool ExitedUnsuccessfully(int exit_status);
// ASSERT_EXIT*, and EXPECT_EXIT*.
#define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (true) { \
+ if (::testing::internal::AlwaysTrue()) { \
const ::testing::internal::RE& gtest_regex = (regex); \
::testing::internal::DeathTest* gtest_dt; \
if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
@@ -172,7 +172,7 @@ bool ExitedUnsuccessfully(int exit_status);
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
::testing::internal::DeathTest::ReturnSentinel \
gtest_sentinel(gtest_dt); \
- GTEST_HIDE_UNREACHABLE_CODE_(statement); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
break; \
} \
@@ -219,6 +219,53 @@ class InternalRunDeathTestFlag {
// the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
+#else // GTEST_HAS_DEATH_TEST
+
+// This macro is used for implementing macros such as
+// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
+// death tests are not supported. Those macros must compile on such systems
+// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
+// systems that support death tests. This allows one to write such a macro
+// on a system that does not support death tests and be sure that it will
+// compile on a death-test supporting system.
+//
+// Parameters:
+// statement - A statement that a macro such as EXPECT_DEATH would test
+// for program termination. This macro has to make sure this
+// statement is compiled but not executed, to ensure that
+// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
+// parameter iff EXPECT_DEATH compiles with it.
+// regex - A regex that a macro such as EXPECT_DEATH would use to test
+// the output of statement. This parameter has to be
+// compiled but not evaluated by this macro, to ensure that
+// this macro only accepts expressions that a macro such as
+// EXPECT_DEATH would accept.
+// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
+// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
+// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
+// compile inside functions where ASSERT_DEATH doesn't
+// compile.
+//
+// The branch that has an always false condition is used to ensure that
+// statement and regex are compiled (and thus syntactically correct) but
+// never executed. The unreachable code macro protects the terminator
+// statement from generating an 'unreachable code' warning in case
+// statement unconditionally returns or throws. The Message constructor at
+// the end allows the syntax of streaming additional messages into the
+// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
+#define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+ if (::testing::internal::AlwaysTrue()) { \
+ GTEST_LOG_(WARNING) \
+ << "Death tests are not supported on this platform.\n" \
+ << "Statement '" #statement "' cannot be verified."; \
+ } else if (::testing::internal::AlwaysFalse()) { \
+ ::testing::internal::RE::PartialMatch(".*", (regex)); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+ terminator; \
+ } else \
+ ::testing::Message()
+
#endif // GTEST_HAS_DEATH_TEST
} // namespace internal
diff --git a/gtest/include/gtest/internal/gtest-internal.h b/gtest/include/gtest/internal/gtest-internal.h
index be37726..7033b0c 100644
--- a/gtest/include/gtest/internal/gtest-internal.h
+++ b/gtest/include/gtest/internal/gtest-internal.h
@@ -107,7 +107,6 @@ class Test; // Represents a test.
class TestInfo; // Information about a test.
class TestPartResult; // Result of a test part.
class UnitTest; // A collection of test cases.
-class UnitTestEventListenerInterface; // Listens to Google Test events.
namespace internal {
@@ -726,8 +725,8 @@ class TypeParameterizedTestCase {
template <GTEST_TEMPLATE_ Fixture, typename Types>
class TypeParameterizedTestCase<Fixture, Templates0, Types> {
public:
- static bool Register(const char* prefix, const char* case_name,
- const char* test_names) {
+ static bool Register(const char* /*prefix*/, const char* /*case_name*/,
+ const char* /*test_names*/) {
return true;
}
};
@@ -746,9 +745,37 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count);
-// A helper for suppressing warnings on unreachable code in some macros.
+// Helpers for suppressing warnings on unreachable code or constant
+// condition.
+
+// Always returns true.
bool AlwaysTrue();
+// Always returns false.
+inline bool AlwaysFalse() { return !AlwaysTrue(); }
+
+// A simple Linear Congruential Generator for generating random
+// numbers with a uniform distribution. Unlike rand() and srand(), it
+// doesn't use global state (and therefore can't interfere with user
+// code). Unlike rand_r(), it's portable. An LCG isn't very random,
+// but it's good enough for our purposes.
+class Random {
+ public:
+ static const UInt32 kMaxRange = 1u << 31;
+
+ explicit Random(UInt32 seed) : state_(seed) {}
+
+ void Reseed(UInt32 seed) { state_ = seed; }
+
+ // Generates a random number from [0, range). Crashes if 'range' is
+ // 0 or greater than kMaxRange.
+ UInt32 Generate(UInt32 range);
+
+ private:
+ UInt32 state_;
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
+};
+
} // namespace internal
} // namespace testing
@@ -757,18 +784,18 @@ bool AlwaysTrue();
= ::testing::Message()
#define GTEST_FATAL_FAILURE_(message) \
- return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE)
+ return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
#define GTEST_NONFATAL_FAILURE_(message) \
- GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE)
+ GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
#define GTEST_SUCCESS_(message) \
- GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS)
+ GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
// Suppresses MSVC warnings 4072 (unreachable code) for the code following
// statement if it returns or throws (or doesn't return or throw in some
// situations).
-#define GTEST_HIDE_UNREACHABLE_CODE_(statement) \
+#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; }
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
@@ -776,7 +803,7 @@ bool AlwaysTrue();
if (const char* gtest_msg = "") { \
bool gtest_caught_expected = false; \
try { \
- GTEST_HIDE_UNREACHABLE_CODE_(statement); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (expected_exception const&) { \
gtest_caught_expected = true; \
@@ -800,7 +827,7 @@ bool AlwaysTrue();
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \
try { \
- GTEST_HIDE_UNREACHABLE_CODE_(statement); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (...) { \
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
@@ -816,7 +843,7 @@ bool AlwaysTrue();
if (const char* gtest_msg = "") { \
bool gtest_caught_any = false; \
try { \
- GTEST_HIDE_UNREACHABLE_CODE_(statement); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (...) { \
gtest_caught_any = true; \
@@ -833,7 +860,7 @@ bool AlwaysTrue();
#define GTEST_TEST_BOOLEAN_(boolexpr, booltext, actual, expected, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (boolexpr) \
+ if (::testing::internal::IsTrue(boolexpr)) \
; \
else \
fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expected)
@@ -842,7 +869,7 @@ bool AlwaysTrue();
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
- GTEST_HIDE_UNREACHABLE_CODE_(statement); \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
gtest_msg = "Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \
diff --git a/gtest/include/gtest/internal/gtest-param-util-generated.h b/gtest/include/gtest/internal/gtest-param-util-generated.h
index ad06e02..1358c32 100644
--- a/gtest/include/gtest/internal/gtest-param-util-generated.h
+++ b/gtest/include/gtest/internal/gtest-param-util-generated.h
@@ -63,6 +63,9 @@ class ValueArray1 {
operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray1& other);
+
const T1 v1_;
};
@@ -78,6 +81,9 @@ class ValueArray2 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray2& other);
+
const T1 v1_;
const T2 v2_;
};
@@ -94,6 +100,9 @@ class ValueArray3 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray3& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -112,6 +121,9 @@ class ValueArray4 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray4& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -131,6 +143,9 @@ class ValueArray5 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray5& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -152,6 +167,9 @@ class ValueArray6 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray6& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -174,6 +192,9 @@ class ValueArray7 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray7& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -198,6 +219,9 @@ class ValueArray8 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray8& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -223,6 +247,9 @@ class ValueArray9 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray9& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -249,6 +276,9 @@ class ValueArray10 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray10& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -277,6 +307,9 @@ class ValueArray11 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray11& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -307,6 +340,9 @@ class ValueArray12 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray12& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -339,6 +375,9 @@ class ValueArray13 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray13& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -372,6 +411,9 @@ class ValueArray14 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray14& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -406,6 +448,9 @@ class ValueArray15 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray15& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -443,6 +488,9 @@ class ValueArray16 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray16& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -481,6 +529,9 @@ class ValueArray17 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray17& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -520,6 +571,9 @@ class ValueArray18 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray18& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -560,6 +614,9 @@ class ValueArray19 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray19& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -602,6 +659,9 @@ class ValueArray20 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray20& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -646,6 +706,9 @@ class ValueArray21 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray21& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -691,6 +754,9 @@ class ValueArray22 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray22& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -739,6 +805,9 @@ class ValueArray23 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray23& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -788,6 +857,9 @@ class ValueArray24 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray24& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -838,6 +910,9 @@ class ValueArray25 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray25& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -890,6 +965,9 @@ class ValueArray26 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray26& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -944,6 +1022,9 @@ class ValueArray27 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray27& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -999,6 +1080,9 @@ class ValueArray28 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray28& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1055,6 +1139,9 @@ class ValueArray29 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray29& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1113,6 +1200,9 @@ class ValueArray30 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray30& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1173,6 +1263,9 @@ class ValueArray31 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray31& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1234,6 +1327,9 @@ class ValueArray32 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray32& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1297,6 +1393,9 @@ class ValueArray33 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray33& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1361,6 +1460,9 @@ class ValueArray34 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray34& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1427,6 +1529,9 @@ class ValueArray35 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray35& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1495,6 +1600,9 @@ class ValueArray36 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray36& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1565,6 +1673,9 @@ class ValueArray37 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray37& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1636,6 +1747,9 @@ class ValueArray38 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray38& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1708,6 +1822,9 @@ class ValueArray39 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray39& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1782,6 +1899,9 @@ class ValueArray40 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray40& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1858,6 +1978,9 @@ class ValueArray41 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray41& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -1935,6 +2058,9 @@ class ValueArray42 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray42& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2013,6 +2139,9 @@ class ValueArray43 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray43& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2093,6 +2222,9 @@ class ValueArray44 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray44& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2174,6 +2306,9 @@ class ValueArray45 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray45& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2257,6 +2392,9 @@ class ValueArray46 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray46& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2343,6 +2481,9 @@ class ValueArray47 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray47& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2430,6 +2571,9 @@ class ValueArray48 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray48& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2518,6 +2662,9 @@ class ValueArray49 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray49& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2607,6 +2754,9 @@ class ValueArray50 {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray50& other);
+
const T1 v1_;
const T2 v2_;
const T3 v3_;
@@ -2757,6 +2907,9 @@ class CartesianProductGenerator2
current2_ == end2_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -2767,11 +2920,14 @@ class CartesianProductGenerator2
const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator2::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator2& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
-};
+}; // class CartesianProductGenerator2
template <typename T1, typename T2, typename T3>
@@ -2879,6 +3035,9 @@ class CartesianProductGenerator3
current3_ == end3_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -2892,12 +3051,15 @@ class CartesianProductGenerator3
const typename ParamGenerator<T3>::iterator end3_;
typename ParamGenerator<T3>::iterator current3_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator3::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator3& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_;
-};
+}; // class CartesianProductGenerator3
template <typename T1, typename T2, typename T3, typename T4>
@@ -3020,6 +3182,9 @@ class CartesianProductGenerator4
current4_ == end4_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -3036,13 +3201,16 @@ class CartesianProductGenerator4
const typename ParamGenerator<T4>::iterator end4_;
typename ParamGenerator<T4>::iterator current4_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator4::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator4& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_;
-};
+}; // class CartesianProductGenerator4
template <typename T1, typename T2, typename T3, typename T4, typename T5>
@@ -3177,6 +3345,9 @@ class CartesianProductGenerator5
current5_ == end5_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -3196,14 +3367,17 @@ class CartesianProductGenerator5
const typename ParamGenerator<T5>::iterator end5_;
typename ParamGenerator<T5>::iterator current5_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator5::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator5& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_;
-};
+}; // class CartesianProductGenerator5
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -3353,6 +3527,9 @@ class CartesianProductGenerator6
current6_ == end6_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -3375,7 +3552,10 @@ class CartesianProductGenerator6
const typename ParamGenerator<T6>::iterator end6_;
typename ParamGenerator<T6>::iterator current6_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator6::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator6& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
@@ -3383,7 +3563,7 @@ class CartesianProductGenerator6
const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_;
-};
+}; // class CartesianProductGenerator6
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -3546,6 +3726,9 @@ class CartesianProductGenerator7
current7_ == end7_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -3571,7 +3754,10 @@ class CartesianProductGenerator7
const typename ParamGenerator<T7>::iterator end7_;
typename ParamGenerator<T7>::iterator current7_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator7::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator7& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
@@ -3580,7 +3766,7 @@ class CartesianProductGenerator7
const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_;
-};
+}; // class CartesianProductGenerator7
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -3758,6 +3944,9 @@ class CartesianProductGenerator8
current8_ == end8_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -3786,7 +3975,10 @@ class CartesianProductGenerator8
const typename ParamGenerator<T8>::iterator end8_;
typename ParamGenerator<T8>::iterator current8_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator8::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator8& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
@@ -3796,7 +3988,7 @@ class CartesianProductGenerator8
const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_;
const ParamGenerator<T8> g8_;
-};
+}; // class CartesianProductGenerator8
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -3987,6 +4179,9 @@ class CartesianProductGenerator9
current9_ == end9_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -4018,7 +4213,10 @@ class CartesianProductGenerator9
const typename ParamGenerator<T9>::iterator end9_;
typename ParamGenerator<T9>::iterator current9_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator9::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator9& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
@@ -4029,7 +4227,7 @@ class CartesianProductGenerator9
const ParamGenerator<T7> g7_;
const ParamGenerator<T8> g8_;
const ParamGenerator<T9> g9_;
-};
+}; // class CartesianProductGenerator9
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -4233,6 +4431,9 @@ class CartesianProductGenerator10
current10_ == end10_;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -4267,7 +4468,10 @@ class CartesianProductGenerator10
const typename ParamGenerator<T10>::iterator end10_;
typename ParamGenerator<T10>::iterator current10_;
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator10::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator10& other);
const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_;
@@ -4279,7 +4483,7 @@ class CartesianProductGenerator10
const ParamGenerator<T8> g8_;
const ParamGenerator<T9> g9_;
const ParamGenerator<T10> g10_;
-};
+}; // class CartesianProductGenerator10
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
@@ -4302,9 +4506,12 @@ CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder2& other);
+
const Generator1 g1_;
const Generator2 g2_;
-};
+}; // class CartesianProductHolder2
template <class Generator1, class Generator2, class Generator3>
class CartesianProductHolder3 {
@@ -4322,10 +4529,13 @@ CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder3& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
-};
+}; // class CartesianProductHolder3
template <class Generator1, class Generator2, class Generator3,
class Generator4>
@@ -4345,11 +4555,14 @@ CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder4& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
const Generator4 g4_;
-};
+}; // class CartesianProductHolder4
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5>
@@ -4370,12 +4583,15 @@ CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder5& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
const Generator4 g4_;
const Generator5 g5_;
-};
+}; // class CartesianProductHolder5
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6>
@@ -4399,13 +4615,16 @@ CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder6& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
const Generator4 g4_;
const Generator5 g5_;
const Generator6 g6_;
-};
+}; // class CartesianProductHolder6
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7>
@@ -4431,6 +4650,9 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder7& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
@@ -4438,7 +4660,7 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
const Generator5 g5_;
const Generator6 g6_;
const Generator7 g7_;
-};
+}; // class CartesianProductHolder7
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7,
@@ -4467,6 +4689,9 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder8& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
@@ -4475,7 +4700,7 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
const Generator6 g6_;
const Generator7 g7_;
const Generator8 g8_;
-};
+}; // class CartesianProductHolder8
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7,
@@ -4507,6 +4732,9 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder9& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
@@ -4516,7 +4744,7 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
const Generator7 g7_;
const Generator8 g8_;
const Generator9 g9_;
-};
+}; // class CartesianProductHolder9
template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7,
@@ -4550,6 +4778,9 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder10& other);
+
const Generator1 g1_;
const Generator2 g2_;
const Generator3 g3_;
@@ -4560,7 +4791,7 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
const Generator8 g8_;
const Generator9 g9_;
const Generator10 g10_;
-};
+}; // class CartesianProductHolder10
#endif // GTEST_HAS_COMBINE
diff --git a/gtest/include/gtest/internal/gtest-param-util-generated.h.pump b/gtest/include/gtest/internal/gtest-param-util-generated.h.pump
index 54b2dc1..2da2872 100644
--- a/gtest/include/gtest/internal/gtest-param-util-generated.h.pump
+++ b/gtest/include/gtest/internal/gtest-param-util-generated.h.pump
@@ -64,6 +64,9 @@ class ValueArray1 {
operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray1& other);
+
const T1 v1_;
};
@@ -83,6 +86,9 @@ class ValueArray$i {
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ValueArray$i& other);
+
$for j [[
const T$j v$(j)_;
@@ -201,6 +207,9 @@ $for j || [[
]];
}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
@@ -212,14 +221,17 @@ $for j [[
]]
ParamType current_value_;
- };
+ }; // class CartesianProductGenerator$i::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductGenerator$i& other);
$for j [[
const ParamGenerator<T$j> g$(j)_;
]]
-};
+}; // class CartesianProductGenerator$i
]]
@@ -250,12 +262,15 @@ $for j,[[
}
private:
+ // No implementation - assignment is unsupported.
+ void operator=(const CartesianProductHolder$i& other);
+
$for j [[
const Generator$j g$(j)_;
]]
-};
+}; // class CartesianProductHolder$i
]]
diff --git a/gtest/include/gtest/internal/gtest-param-util.h b/gtest/include/gtest/internal/gtest-param-util.h
index 34361ab..dcc5494 100644
--- a/gtest/include/gtest/internal/gtest-param-util.h
+++ b/gtest/include/gtest/internal/gtest-param-util.h
@@ -248,6 +248,9 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
: base_(other.base_), value_(other.value_), index_(other.index_),
step_(other.step_) {}
+ // No implementation - assignment is unsupported.
+ void operator=(const Iterator& other);
+
const ParamGeneratorInterface<T>* const base_;
T value_;
int index_;
@@ -263,6 +266,9 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
return end_index;
}
+ // No implementation - assignment is unsupported.
+ void operator=(const RangeGenerator& other);
+
const T begin_;
const T end_;
const IncrementT step_;
@@ -349,7 +355,10 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
// Use of scoped_ptr helps manage cached value's lifetime,
// which is bound by the lifespan of the iterator itself.
mutable scoped_ptr<const T> value_;
- };
+ }; // class ValuesInIteratorRangeGenerator::Iterator
+
+ // No implementation - assignment is unsupported.
+ void operator=(const ValuesInIteratorRangeGenerator& other);
const ContainerType container_;
}; // class ValuesInIteratorRangeGenerator
diff --git a/gtest/include/gtest/internal/gtest-port.h b/gtest/include/gtest/internal/gtest-port.h
index a5adbc0..ee97881 100644
--- a/gtest/include/gtest/internal/gtest-port.h
+++ b/gtest/include/gtest/internal/gtest-port.h
@@ -77,7 +77,10 @@
// GTEST_OS_MAC - Mac OS X
// GTEST_OS_SOLARIS - Sun Solaris
// GTEST_OS_SYMBIAN - Symbian
-// GTEST_OS_WINDOWS - Windows
+// GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile)
+// GTEST_OS_WINDOWS_DESKTOP - Windows Desktop
+// GTEST_OS_WINDOWS_MINGW - MinGW
+// GTEST_OS_WINODWS_MOBILE - Windows Mobile
// GTEST_OS_ZOS - z/OS
//
// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
@@ -184,6 +187,13 @@
#define GTEST_OS_SYMBIAN 1
#elif defined _WIN32
#define GTEST_OS_WINDOWS 1
+#ifdef _WIN32_WCE
+#define GTEST_OS_WINDOWS_MOBILE 1
+#elif defined(__MINGW__) || defined(__MINGW32__)
+#define GTEST_OS_WINDOWS_MINGW 1
+#else
+#define GTEST_OS_WINDOWS_DESKTOP 1
+#endif // _WIN32_WCE
#elif defined __APPLE__
#define GTEST_OS_MAC 1
#elif defined __linux__
@@ -210,10 +220,10 @@
#elif GTEST_OS_WINDOWS
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
#include <direct.h> // NOLINT
#include <io.h> // NOLINT
-#endif // !_WIN32_WCE
+#endif
// <regex.h> is not available on Windows. Use our own simple regex
// implementation instead.
@@ -449,11 +459,9 @@
// (this is covered by GTEST_HAS_STD_STRING guard).
// 3. abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
-#if GTEST_HAS_STD_STRING && (GTEST_OS_LINUX || \
- GTEST_OS_MAC || \
- GTEST_OS_CYGWIN || \
- (GTEST_OS_WINDOWS && (_MSC_VER >= 1400) && \
- !defined(_WIN32_WCE)))
+#if GTEST_HAS_STD_STRING && \
+ (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
+ (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
#define GTEST_HAS_DEATH_TEST 1
#include <vector> // NOLINT
#endif
@@ -569,6 +577,10 @@ typedef ::std::stringstream StrStream;
typedef ::std::strstream StrStream;
#endif // GTEST_HAS_STD_STRING
+// A helper for suppressing warnings on constant condition. It just
+// returns 'condition'.
+bool IsTrue(bool condition);
+
// Defines scoped_ptr.
// This implementation of scoped_ptr is PARTIAL - it only contains
@@ -591,7 +603,7 @@ class scoped_ptr {
void reset(T* p = NULL) {
if (p != ptr_) {
- if (sizeof(T) > 0) { // Makes sure T is a complete type.
+ if (IsTrue(sizeof(T) > 0)) { // Makes sure T is a complete type.
delete ptr_;
}
ptr_ = p;
@@ -672,7 +684,8 @@ class RE {
};
// Defines logging utilities:
-// GTEST_LOG_() - logs messages at the specified severity level.
+// GTEST_LOG_(severity) - logs messages at the specified severity level. The
+// message itself is streamed into the macro.
// LogToStderr() - directs all log messages to stderr.
// FlushInfoLog() - flushes informational log messages.
@@ -683,13 +696,27 @@ enum GTestLogSeverity {
GTEST_FATAL
};
-void GTestLog(GTestLogSeverity severity, const char* file,
- int line, const char* msg);
+// Formats log entry severity, provides a stream object for streaming the
+// log message, and terminates the message with a newline when going out of
+// scope.
+class GTestLog {
+ public:
+ GTestLog(GTestLogSeverity severity, const char* file, int line);
+
+ // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
+ ~GTestLog();
-#define GTEST_LOG_(severity, msg)\
- ::testing::internal::GTestLog(\
- ::testing::internal::GTEST_##severity, __FILE__, __LINE__, \
- (::testing::Message() << (msg)).GetString().c_str())
+ ::std::ostream& GetStream() { return ::std::cerr; }
+
+ private:
+ const GTestLogSeverity severity_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
+};
+
+#define GTEST_LOG_(severity) \
+ ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
+ __FILE__, __LINE__).GetStream()
inline void LogToStderr() {}
inline void FlushInfoLog() { fflush(NULL); }
@@ -820,29 +847,29 @@ inline int StrCaseCmp(const char* s1, const char* s2) {
}
inline char* StrDup(const char* src) { return strdup(src); }
#else // !__BORLANDC__
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
inline int IsATTY(int /* fd */) { return 0; }
-#else // !_WIN32_WCE
+#else
inline int IsATTY(int fd) { return _isatty(fd); }
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
inline int StrCaseCmp(const char* s1, const char* s2) {
return _stricmp(s1, s2);
}
inline char* StrDup(const char* src) { return _strdup(src); }
#endif // __BORLANDC__
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
// time and thus not defined there.
-#else // !_WIN32_WCE
+#else
inline int FileNo(FILE* file) { return _fileno(file); }
inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
inline int RmDir(const char* dir) { return _rmdir(dir); }
inline bool IsDir(const StatStruct& st) {
return (_S_IFDIR & st.st_mode) != 0;
}
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
#else
@@ -876,20 +903,20 @@ inline const char* StrNCpy(char* dest, const char* src, size_t n) {
// StrError() aren't needed on Windows CE at this time and thus not
// defined there.
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
inline int ChDir(const char* dir) { return chdir(dir); }
#endif
inline FILE* FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
return freopen(path, mode, stream);
}
inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
#endif
inline int FClose(FILE* fp) { return fclose(fp); }
-#ifndef _WIN32_WCE
+#if !GTEST_OS_WINDOWS_MOBILE
inline int Read(int fd, void* buf, unsigned int count) {
return static_cast<int>(read(fd, buf, count));
}
@@ -900,7 +927,8 @@ inline int Close(int fd) { return close(fd); }
inline const char* StrError(int errnum) { return strerror(errnum); }
#endif
inline const char* GetEnv(const char* name) {
-#ifdef _WIN32_WCE // We are on Windows CE, which has no environment variables.
+#if GTEST_OS_WINDOWS_MOBILE
+ // We are on Windows CE, which has no environment variables.
return NULL;
#elif defined(__BORLANDC__)
// Environment variables which we programmatically clear will be set to the
@@ -916,14 +944,14 @@ inline const char* GetEnv(const char* name) {
#pragma warning(pop) // Restores the warning state.
#endif
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
// Windows CE has no C library. The abort() function is used in
// several places in Google Test. This implementation provides a reasonable
// imitation of standard behaviour.
void Abort();
#else
inline void Abort() { abort(); }
-#endif // _WIN32_WCE
+#endif // GTEST_OS_WINDOWS_MOBILE
} // namespace posix
@@ -1011,38 +1039,12 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
// condition itself, plus additional message streamed into it, if any,
// and then it aborts the program. It aborts the program irrespective of
// whether it is built in the debug mode or not.
-class GTestCheckProvider {
- public:
- GTestCheckProvider(const char* condition, const char* file, int line) {
- FormatFileLocation(file, line);
- ::std::cerr << " ERROR: Condition " << condition << " failed. ";
- }
- ~GTestCheckProvider() {
- ::std::cerr << ::std::endl;
- posix::Abort();
- }
- void FormatFileLocation(const char* file, int line) {
- if (file == NULL)
- file = "unknown file";
- if (line < 0) {
- ::std::cerr << file << ":";
- } else {
-#if _MSC_VER
- ::std::cerr << file << "(" << line << "):";
-#else
- ::std::cerr << file << ":" << line << ":";
-#endif
- }
- }
- ::std::ostream& GetStream() { return ::std::cerr; }
-};
#define GTEST_CHECK_(condition) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (condition) \
+ if (::testing::internal::IsTrue(condition)) \
; \
else \
- ::testing::internal::GTestCheckProvider(\
- #condition, __FILE__, __LINE__).GetStream()
+ GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
// Macro for referencing flags.
#define GTEST_FLAG(name) FLAGS_gtest_##name
diff --git a/gtest/include/gtest/internal/gtest-string.h b/gtest/include/gtest/internal/gtest-string.h
index 566a6b5..4bc8241 100644
--- a/gtest/include/gtest/internal/gtest-string.h
+++ b/gtest/include/gtest/internal/gtest-string.h
@@ -80,19 +80,6 @@ class String {
public:
// Static utility methods
- // Returns the input if it's not NULL, otherwise returns "(null)".
- // This function serves two purposes:
- //
- // 1. ShowCString(NULL) has type 'const char *', instead of the
- // type of NULL (which is int).
- //
- // 2. In MSVC, streaming a null char pointer to StrStream generates
- // an access violation, so we need to convert NULL to "(null)"
- // before streaming it.
- static inline const char* ShowCString(const char* c_str) {
- return c_str ? c_str : "(null)";
- }
-
// Returns the input enclosed in double quotes if it's not NULL;
// otherwise returns "(null)". For example, "\"Hello\"" is returned
// for input "Hello".
@@ -111,7 +98,7 @@ class String {
// memory using malloc().
static const char* CloneCString(const char* c_str);
-#ifdef _WIN32_WCE
+#if GTEST_OS_WINDOWS_MOBILE
// Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
// able to pass strings to Win32 APIs on CE we need to convert them
// to 'Unicode', UTF-16.
@@ -200,22 +187,29 @@ class String {
// C'tors
// The default c'tor constructs a NULL string.
- String() : c_str_(NULL) {}
+ String() : c_str_(NULL), length_(0) {}
// Constructs a String by cloning a 0-terminated C string.
- String(const char* c_str) : c_str_(NULL) { // NOLINT
- *this = c_str;
+ String(const char* c_str) { // NOLINT
+ if (c_str == NULL) {
+ c_str_ = NULL;
+ length_ = 0;
+ } else {
+ ConstructNonNull(c_str, strlen(c_str));
+ }
}
// Constructs a String by copying a given number of chars from a
- // buffer. E.g. String("hello", 3) will create the string "hel".
- String(const char* buffer, size_t len);
+ // buffer. E.g. String("hello", 3) creates the string "hel",
+ // String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
+ // and String(NULL, 1) results in access violation.
+ String(const char* buffer, size_t length) {
+ ConstructNonNull(buffer, length);
+ }
// The copy c'tor creates a new copy of the string. The two
// String objects do not share content.
- String(const String& str) : c_str_(NULL) {
- *this = str;
- }
+ String(const String& str) : c_str_(NULL), length_(0) { *this = str; }
// D'tor. String is intended to be a final class, so the d'tor
// doesn't need to be virtual.
@@ -228,21 +222,23 @@ class String {
// character to a String will result in the prefix up to the first
// NUL character.
#if GTEST_HAS_STD_STRING
- String(const ::std::string& str) : c_str_(NULL) { *this = str.c_str(); }
+ String(const ::std::string& str) {
+ ConstructNonNull(str.c_str(), str.length());
+ }
- operator ::std::string() const { return ::std::string(c_str_); }
+ operator ::std::string() const { return ::std::string(c_str(), length()); }
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
- String(const ::string& str) : c_str_(NULL) { *this = str.c_str(); }
+ String(const ::string& str) {
+ ConstructNonNull(str.c_str(), str.length());
+ }
- operator ::string() const { return ::string(c_str_); }
+ operator ::string() const { return ::string(c_str(), length()); }
#endif // GTEST_HAS_GLOBAL_STRING
// Returns true iff this is an empty string (i.e. "").
- bool empty() const {
- return (c_str_ != NULL) && (*c_str_ == '\0');
- }
+ bool empty() const { return (c_str() != NULL) && (length() == 0); }
// Compares this with another String.
// Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
@@ -251,19 +247,15 @@ class String {
// Returns true iff this String equals the given C string. A NULL
// string and a non-NULL string are considered not equal.
- bool operator==(const char* c_str) const {
- return CStringEquals(c_str_, c_str);
- }
+ bool operator==(const char* c_str) const { return Compare(c_str) == 0; }
- // Returns true iff this String is less than the given C string. A NULL
- // string is considered less than "".
+ // Returns true iff this String is less than the given String. A
+ // NULL string is considered less than "".
bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
// Returns true iff this String doesn't equal the given C string. A NULL
// string and a non-NULL string are considered not equal.
- bool operator!=(const char* c_str) const {
- return !CStringEquals(c_str_, c_str);
- }
+ bool operator!=(const char* c_str) const { return !(*this == c_str); }
// Returns true iff this String ends with the given suffix. *Any*
// String is considered to end with a NULL or empty suffix.
@@ -273,45 +265,66 @@ class String {
// case. Any String is considered to end with a NULL or empty suffix.
bool EndsWithCaseInsensitive(const char* suffix) const;
- // Returns the length of the encapsulated string, or -1 if the
+ // Returns the length of the encapsulated string, or 0 if the
// string is NULL.
- int GetLength() const {
- return c_str_ ? static_cast<int>(strlen(c_str_)) : -1;
- }
+ size_t length() const { return length_; }
// Gets the 0-terminated C string this String object represents.
// The String object still owns the string. Therefore the caller
// should NOT delete the return value.
const char* c_str() const { return c_str_; }
- // Sets the 0-terminated C string this String object represents.
- // The old string in this object is deleted, and this object will
- // own a clone of the input string. This function copies only up to
- // length bytes (plus a terminating null byte), or until the first
- // null byte, whichever comes first.
- //
- // This function works even when the c_str parameter has the same
- // value as that of the c_str_ field.
- void Set(const char* c_str, size_t length);
-
// Assigns a C string to this object. Self-assignment works.
- const String& operator=(const char* c_str);
+ const String& operator=(const char* c_str) { return *this = String(c_str); }
// Assigns a String object to this object. Self-assignment works.
- const String& operator=(const String &rhs) {
- *this = rhs.c_str_;
+ const String& operator=(const String& rhs) {
+ if (this != &rhs) {
+ delete[] c_str_;
+ if (rhs.c_str() == NULL) {
+ c_str_ = NULL;
+ length_ = 0;
+ } else {
+ ConstructNonNull(rhs.c_str(), rhs.length());
+ }
+ }
+
return *this;
}
private:
- const char* c_str_;
-};
+ // Constructs a non-NULL String from the given content. This
+ // function can only be called when data_ has not been allocated.
+ // ConstructNonNull(NULL, 0) results in an empty string ("").
+ // ConstructNonNull(NULL, non_zero) is undefined behavior.
+ void ConstructNonNull(const char* buffer, size_t length) {
+ char* const str = new char[length + 1];
+ memcpy(str, buffer, length);
+ str[length] = '\0';
+ c_str_ = str;
+ length_ = length;
+ }
-// Streams a String to an ostream.
-inline ::std::ostream& operator <<(::std::ostream& os, const String& str) {
- // We call String::ShowCString() to convert NULL to "(null)".
- // Otherwise we'll get an access violation on Windows.
- return os << String::ShowCString(str.c_str());
+ const char* c_str_;
+ size_t length_;
+}; // class String
+
+// Streams a String to an ostream. Each '\0' character in the String
+// is replaced with "\\0".
+inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
+ if (str.c_str() == NULL) {
+ os << "(null)";
+ } else {
+ const char* const c_str = str.c_str();
+ for (size_t i = 0; i != str.length(); i++) {
+ if (c_str[i] == '\0') {
+ os << "\\0";
+ } else {
+ os << c_str[i];
+ }
+ }
+ }
+ return os;
}
// Gets the content of the StrStream's buffer as a String. Each '\0'