Many changes:
- appends "_" to internal macro names (by Markus Heule). - makes Google Test work with newer versions of tools on Symbian and Windows CE (by Mika Raento). - adds the (ASSERT|EXPECT)_NO_FATAL_FAILURE macros (by Markus Heule). - changes EXPECT_(NON|)FATAL_FAILURE to catch failures in the current thread only (by Markus Heule). - adds the EXPECT_(NON|)FATAL_FAILURE_ON_ALL_THREADS macros (by Markus Heule). - adds GTEST_HAS_PTHREAD and GTEST_IS_THREADSAFE to indicate the availability of <pthread.h> and Google Test's thread-safety (by Zhanyong Wan). - adds scons/SConscript for building with scons (by Joi Sigurdsson). - adds src/gtest-all.cc for building Google Test from a single file (by Markus Heule). - updates the xcode project to include new tests (by Preston Jackson).
This commit is contained in:
@@ -47,7 +47,7 @@ namespace testing {
|
||||
// from the start, running only a single death test, or "fast",
|
||||
// meaning that the child process will execute the test logic immediately
|
||||
// after forking.
|
||||
GTEST_DECLARE_string(death_test_style);
|
||||
GTEST_DECLARE_string_(death_test_style);
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
|
||||
@@ -104,12 +104,12 @@ GTEST_DECLARE_string(death_test_style);
|
||||
// integer exit status that satisfies predicate, and emitting error output
|
||||
// that matches regex.
|
||||
#define ASSERT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST(statement, predicate, regex, GTEST_FATAL_FAILURE)
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
|
||||
|
||||
// Like ASSERT_EXIT, but continues on to successive tests in the
|
||||
// test case, if any:
|
||||
#define EXPECT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST(statement, predicate, regex, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Asserts that a given statement causes the program to exit, either by
|
||||
// explicitly exiting with a nonzero exit code or being killed by a
|
||||
|
||||
@@ -102,7 +102,7 @@ class Message {
|
||||
}
|
||||
|
||||
~Message() { delete ss_; }
|
||||
#ifdef __SYMBIAN32__
|
||||
#ifdef GTEST_OS_SYMBIAN
|
||||
// Streams a value (either a pointer or not) to this object.
|
||||
template <typename T>
|
||||
inline Message& operator <<(const T& value) {
|
||||
@@ -139,7 +139,7 @@ class Message {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif // __SYMBIAN32__
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// Since the basic IO manipulators are overloaded for both narrow
|
||||
// and wide streams, we have to provide this specialized definition
|
||||
@@ -187,7 +187,7 @@ class Message {
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef __SYMBIAN32__
|
||||
#ifdef GTEST_OS_SYMBIAN
|
||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
||||
// decide between class template specializations for T and T*, so a
|
||||
@@ -204,7 +204,7 @@ class Message {
|
||||
inline void StreamHelper(internal::false_type dummy, const T& value) {
|
||||
::GTestStreamToHelper(ss_, value);
|
||||
}
|
||||
#endif // __SYMBIAN32__
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// We'll hold the text streamed to this object here.
|
||||
internal::StrStream* const ss_;
|
||||
|
||||
@@ -39,124 +39,34 @@
|
||||
|
||||
namespace testing {
|
||||
|
||||
// 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:
|
||||
// C'tor. TestPartResult does NOT have a default constructor.
|
||||
// Always use this constructor (with parameters) to create a
|
||||
// TestPartResult object.
|
||||
TestPartResult(TestPartResultType type,
|
||||
const char* file_name,
|
||||
int line_number,
|
||||
const char* message)
|
||||
: type_(type),
|
||||
file_name_(file_name),
|
||||
line_number_(line_number),
|
||||
summary_(ExtractSummary(message)),
|
||||
message_(message) {
|
||||
}
|
||||
|
||||
// Gets the outcome of the test part.
|
||||
TestPartResultType type() const { return type_; }
|
||||
|
||||
// Gets the name of the source file where the test part took place, or
|
||||
// NULL if it's unknown.
|
||||
const char* file_name() const { return file_name_.c_str(); }
|
||||
|
||||
// Gets the line in the source file where the test part took place,
|
||||
// or -1 if it's unknown.
|
||||
int line_number() const { return line_number_; }
|
||||
|
||||
// Gets the summary of the failure message.
|
||||
const char* summary() const { return summary_.c_str(); }
|
||||
|
||||
// Gets the message associated with the test part.
|
||||
const char* message() const { return message_.c_str(); }
|
||||
|
||||
// Returns true iff the test part passed.
|
||||
bool passed() const { return type_ == TPRT_SUCCESS; }
|
||||
|
||||
// Returns true iff the test part failed.
|
||||
bool failed() const { return type_ != TPRT_SUCCESS; }
|
||||
|
||||
// Returns true iff the test part non-fatally failed.
|
||||
bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; }
|
||||
|
||||
// Returns true iff the test part fatally failed.
|
||||
bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; }
|
||||
private:
|
||||
TestPartResultType type_;
|
||||
|
||||
// Gets the summary of the failure message by omitting the stack
|
||||
// trace in it.
|
||||
static internal::String ExtractSummary(const char* message);
|
||||
|
||||
// The name of the source file where the test part took place, or
|
||||
// NULL if the source file is unknown.
|
||||
internal::String file_name_;
|
||||
// The line in the source file where the test part took place, or -1
|
||||
// if the line number is unknown.
|
||||
int line_number_;
|
||||
internal::String summary_; // The test failure summary.
|
||||
internal::String message_; // The test failure message.
|
||||
};
|
||||
|
||||
// Prints a TestPartResult object.
|
||||
std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
|
||||
|
||||
// An array of TestPartResult objects.
|
||||
//
|
||||
// We define this class as we cannot use STL containers when compiling
|
||||
// Google Test with MSVC 7.1 and exceptions disabled.
|
||||
//
|
||||
// Don't inherit from TestPartResultArray as its destructor is not
|
||||
// virtual.
|
||||
class TestPartResultArray {
|
||||
public:
|
||||
TestPartResultArray();
|
||||
~TestPartResultArray();
|
||||
|
||||
// Appends the given TestPartResult to the array.
|
||||
void Append(const TestPartResult& result);
|
||||
|
||||
// Returns the TestPartResult at the given index (0-based).
|
||||
const TestPartResult& GetTestPartResult(int index) const;
|
||||
|
||||
// Returns the number of TestPartResult objects in the array.
|
||||
int size() const;
|
||||
private:
|
||||
// Internally we use a list to simulate the array. Yes, this means
|
||||
// that random access is O(N) in time, but it's OK for its purpose.
|
||||
internal::List<TestPartResult>* const list_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(TestPartResultArray);
|
||||
};
|
||||
|
||||
// This interface knows how to report a test part result.
|
||||
class TestPartResultReporterInterface {
|
||||
public:
|
||||
virtual ~TestPartResultReporterInterface() {}
|
||||
|
||||
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
|
||||
};
|
||||
|
||||
// This helper class can be used to mock out Google Test failure reporting
|
||||
// so that we can test Google Test or code that builds on Google Test.
|
||||
//
|
||||
// An object of this class appends a TestPartResult object to the
|
||||
// TestPartResultArray object given in the constructor whenever a
|
||||
// Google Test failure is reported.
|
||||
// TestPartResultArray object given in the constructor whenever a Google Test
|
||||
// failure is reported. It can either intercept only failures that are
|
||||
// generated in the same thread that created this object or it can intercept
|
||||
// all generated failures. The scope of this mock object can be controlled with
|
||||
// the second argument to the two arguments constructor.
|
||||
class ScopedFakeTestPartResultReporter
|
||||
: public TestPartResultReporterInterface {
|
||||
public:
|
||||
// The two possible mocking modes of this object.
|
||||
enum InterceptMode {
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures.
|
||||
INTERCEPT_ALL_THREADS // Intercepts all failures.
|
||||
};
|
||||
|
||||
// The c'tor sets this object as the test part result reporter used
|
||||
// by Google Test. The 'result' parameter specifies where to report the
|
||||
// results.
|
||||
// results. This reporter will only catch failures generated in the current
|
||||
// thread. DEPRECATED
|
||||
explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
|
||||
|
||||
// Same as above, but you can choose the interception scope of this object.
|
||||
ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
|
||||
TestPartResultArray* result);
|
||||
|
||||
// The d'tor restores the previous test part result reporter.
|
||||
virtual ~ScopedFakeTestPartResultReporter();
|
||||
|
||||
@@ -167,10 +77,13 @@ class ScopedFakeTestPartResultReporter
|
||||
// interface.
|
||||
virtual void ReportTestPartResult(const TestPartResult& result);
|
||||
private:
|
||||
TestPartResultReporterInterface* const old_reporter_;
|
||||
void Init();
|
||||
|
||||
const InterceptMode intercept_mode_;
|
||||
TestPartResultReporterInterface* old_reporter_;
|
||||
TestPartResultArray* const result_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(ScopedFakeTestPartResultReporter);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
@@ -192,28 +105,53 @@ class SingleFailureChecker {
|
||||
const TestPartResultType type_;
|
||||
const String substr_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(SingleFailureChecker);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
|
||||
};
|
||||
|
||||
// Helper macro to test that statement generates exactly one fatal failure,
|
||||
// which contains the substring 'substr' in its failure message, when a scoped
|
||||
// test result reporter of the given interception mode is used.
|
||||
#define GTEST_EXPECT_NONFATAL_FAILURE_(statement, substr, intercept_mode)\
|
||||
do {\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
intercept_mode, >est_failures);\
|
||||
statement;\
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace testing
|
||||
|
||||
// A macro for testing Google Test assertions or code that's expected to
|
||||
// generate Google Test fatal failures. It verifies that the given
|
||||
// A set of macros for testing Google Test assertions or code that's expected
|
||||
// to generate Google Test fatal failures. It verifies that the given
|
||||
// statement will cause exactly one fatal Google Test failure with 'substr'
|
||||
// being part of the failure message.
|
||||
//
|
||||
// Implementation note: The verification is done in the destructor of
|
||||
// SingleFailureChecker, to make sure that it's done even when
|
||||
// 'statement' throws an exception.
|
||||
// There are two different versions of this macro. EXPECT_FATAL_FAILURE only
|
||||
// affects and considers failures generated in the current thread and
|
||||
// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
|
||||
//
|
||||
// The verification of the assertion is done correctly even when the statement
|
||||
// throws an exception or aborts the current function.
|
||||
//
|
||||
// Known restrictions:
|
||||
// - 'statement' cannot reference local non-static variables or
|
||||
// non-static members of the current object.
|
||||
// - 'statement' cannot return a value.
|
||||
// - You cannot stream a failure message to this macro.
|
||||
#define EXPECT_FATAL_FAILURE(statement, substr) do {\
|
||||
//
|
||||
// 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.
|
||||
#define EXPECT_FATAL_FAILURE(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper {\
|
||||
public:\
|
||||
static void Execute() { statement; }\
|
||||
@@ -223,31 +161,73 @@ class SingleFailureChecker {
|
||||
>est_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
>est_failures);\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
||||
GTestExpectFatalFailureHelper::Execute();\
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper {\
|
||||
public:\
|
||||
static void Execute() { statement; }\
|
||||
};\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ALL_THREADS, >est_failures);\
|
||||
GTestExpectFatalFailureHelper::Execute();\
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
// A macro for testing Google Test assertions or code that's expected to
|
||||
// generate Google Test non-fatal failures. It asserts that the given
|
||||
// statement will cause exactly one non-fatal Google Test failure with
|
||||
// 'substr' being part of the failure message.
|
||||
// statement will cause exactly one non-fatal Google Test failure with 'substr'
|
||||
// being part of the failure message.
|
||||
//
|
||||
// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
|
||||
// affects and considers failures generated in the current thread and
|
||||
// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
|
||||
//
|
||||
// 'statement' is allowed to reference local variables and members of
|
||||
// the current object.
|
||||
//
|
||||
// Implementation note: The verification is done in the destructor of
|
||||
// SingleFailureChecker, to make sure that it's done even when
|
||||
// 'statement' throws an exception or aborts the function.
|
||||
// The verification of the assertion is done correctly even when the statement
|
||||
// throws an exception or aborts the current function.
|
||||
//
|
||||
// Known restrictions:
|
||||
// - You cannot stream a failure message to this macro.
|
||||
#define EXPECT_NONFATAL_FAILURE(statement, substr) do {\
|
||||
//
|
||||
// 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.
|
||||
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
|
||||
do {\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
||||
statement;\
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do {\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
|
||||
>est_failures);\
|
||||
statement;\
|
||||
}\
|
||||
|
||||
179
include/gtest/gtest-test-part.h
Normal file
179
include/gtest/gtest-test-part.h
Normal file
@@ -0,0 +1,179 @@
|
||||
// Copyright 2008, 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.
|
||||
//
|
||||
// Author: mheule@google.com (Markus Heule)
|
||||
//
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
|
||||
#include <iosfwd>
|
||||
#include <gtest/internal/gtest-internal.h>
|
||||
#include <gtest/internal/gtest-string.h>
|
||||
|
||||
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:
|
||||
// C'tor. TestPartResult does NOT have a default constructor.
|
||||
// Always use this constructor (with parameters) to create a
|
||||
// TestPartResult object.
|
||||
TestPartResult(TestPartResultType type,
|
||||
const char* file_name,
|
||||
int line_number,
|
||||
const char* message)
|
||||
: type_(type),
|
||||
file_name_(file_name),
|
||||
line_number_(line_number),
|
||||
summary_(ExtractSummary(message)),
|
||||
message_(message) {
|
||||
}
|
||||
|
||||
// Gets the outcome of the test part.
|
||||
TestPartResultType type() const { return type_; }
|
||||
|
||||
// Gets the name of the source file where the test part took place, or
|
||||
// NULL if it's unknown.
|
||||
const char* file_name() const { return file_name_.c_str(); }
|
||||
|
||||
// Gets the line in the source file where the test part took place,
|
||||
// or -1 if it's unknown.
|
||||
int line_number() const { return line_number_; }
|
||||
|
||||
// Gets the summary of the failure message.
|
||||
const char* summary() const { return summary_.c_str(); }
|
||||
|
||||
// Gets the message associated with the test part.
|
||||
const char* message() const { return message_.c_str(); }
|
||||
|
||||
// Returns true iff the test part passed.
|
||||
bool passed() const { return type_ == TPRT_SUCCESS; }
|
||||
|
||||
// Returns true iff the test part failed.
|
||||
bool failed() const { return type_ != TPRT_SUCCESS; }
|
||||
|
||||
// Returns true iff the test part non-fatally failed.
|
||||
bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; }
|
||||
|
||||
// Returns true iff the test part fatally failed.
|
||||
bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; }
|
||||
private:
|
||||
TestPartResultType type_;
|
||||
|
||||
// Gets the summary of the failure message by omitting the stack
|
||||
// trace in it.
|
||||
static internal::String ExtractSummary(const char* message);
|
||||
|
||||
// The name of the source file where the test part took place, or
|
||||
// NULL if the source file is unknown.
|
||||
internal::String file_name_;
|
||||
// The line in the source file where the test part took place, or -1
|
||||
// if the line number is unknown.
|
||||
int line_number_;
|
||||
internal::String summary_; // The test failure summary.
|
||||
internal::String message_; // The test failure message.
|
||||
};
|
||||
|
||||
// Prints a TestPartResult object.
|
||||
std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
|
||||
|
||||
// An array of TestPartResult objects.
|
||||
//
|
||||
// We define this class as we cannot use STL containers when compiling
|
||||
// Google Test with MSVC 7.1 and exceptions disabled.
|
||||
//
|
||||
// Don't inherit from TestPartResultArray as its destructor is not
|
||||
// virtual.
|
||||
class TestPartResultArray {
|
||||
public:
|
||||
TestPartResultArray();
|
||||
~TestPartResultArray();
|
||||
|
||||
// Appends the given TestPartResult to the array.
|
||||
void Append(const TestPartResult& result);
|
||||
|
||||
// Returns the TestPartResult at the given index (0-based).
|
||||
const TestPartResult& GetTestPartResult(int index) const;
|
||||
|
||||
// Returns the number of TestPartResult objects in the array.
|
||||
int size() const;
|
||||
private:
|
||||
// Internally we use a list to simulate the array. Yes, this means
|
||||
// that random access is O(N) in time, but it's OK for its purpose.
|
||||
internal::List<TestPartResult>* const list_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
|
||||
};
|
||||
|
||||
// This interface knows how to report a test part result.
|
||||
class TestPartResultReporterInterface {
|
||||
public:
|
||||
virtual ~TestPartResultReporterInterface() {}
|
||||
|
||||
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
|
||||
// statement generates new fatal failures. To do so it registers itself as the
|
||||
// current test part result reporter. Besides checking if fatal failures were
|
||||
// reported, it only delegates the reporting to the former result reporter.
|
||||
// The original result reporter is restored in the destructor.
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
class HasNewFatalFailureHelper : public TestPartResultReporterInterface {
|
||||
public:
|
||||
HasNewFatalFailureHelper();
|
||||
virtual ~HasNewFatalFailureHelper();
|
||||
virtual void ReportTestPartResult(const TestPartResult& result);
|
||||
bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
|
||||
private:
|
||||
bool has_new_fatal_failure_;
|
||||
TestPartResultReporterInterface* original_reporter_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
@@ -53,7 +53,6 @@
|
||||
|
||||
// The following platform macros are used throughout Google Test:
|
||||
// _WIN32_WCE Windows CE (set in project files)
|
||||
// __SYMBIAN32__ Symbian (set by Symbian tool chain)
|
||||
//
|
||||
// Note that even though _MSC_VER and _WIN32_WCE really indicate a compiler
|
||||
// and a Win32 implementation, respectively, we use them to indicate the
|
||||
@@ -68,6 +67,7 @@
|
||||
#include <gtest/gtest-death-test.h>
|
||||
#include <gtest/gtest-message.h>
|
||||
#include <gtest/gtest_prod.h>
|
||||
#include <gtest/gtest-test-part.h>
|
||||
#include <gtest/gtest-typed-test.h>
|
||||
|
||||
// Depending on the platform, different string classes are available.
|
||||
@@ -97,19 +97,11 @@ const int kMaxStackTraceDepth = 100;
|
||||
|
||||
// This flag specifies the maximum number of stack frames to be
|
||||
// printed in a failure message.
|
||||
GTEST_DECLARE_int32(stack_trace_depth);
|
||||
GTEST_DECLARE_int32_(stack_trace_depth);
|
||||
|
||||
// This flag controls whether Google Test includes Google Test internal
|
||||
// stack frames in failure stack traces.
|
||||
GTEST_DECLARE_bool(show_internal_stack_frames);
|
||||
|
||||
// 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.
|
||||
};
|
||||
GTEST_DECLARE_bool_(show_internal_stack_frames);
|
||||
|
||||
namespace internal {
|
||||
|
||||
@@ -308,7 +300,7 @@ class Test {
|
||||
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
|
||||
|
||||
// We disallow copying Tests.
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(Test);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
|
||||
};
|
||||
|
||||
|
||||
@@ -393,7 +385,7 @@ class TestInfo {
|
||||
// An opaque implementation object.
|
||||
internal::TestInfoImpl* impl_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(TestInfo);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
|
||||
};
|
||||
|
||||
// An Environment object is capable of setting up and tearing down an
|
||||
@@ -477,7 +469,7 @@ class UnitTest {
|
||||
// This method can only be called from the main thread.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
int Run() GTEST_MUST_USE_RESULT;
|
||||
int Run() GTEST_MUST_USE_RESULT_;
|
||||
|
||||
// Returns the working directory when the first TEST() or TEST_F()
|
||||
// was executed. The UnitTest object owns the string.
|
||||
@@ -523,7 +515,7 @@ class UnitTest {
|
||||
internal::UnitTestImpl* impl_;
|
||||
|
||||
// We disallow copying UnitTest.
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(UnitTest);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
|
||||
};
|
||||
|
||||
// A convenient wrapper for adding an environment for the test
|
||||
@@ -707,7 +699,7 @@ class EqHelper<true> {
|
||||
// with gcc 4.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
#define GTEST_IMPL_CMP_HELPER(op_name, op)\
|
||||
#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
|
||||
template <typename T1, typename T2>\
|
||||
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
|
||||
const T1& val1, const T2& val2) {\
|
||||
@@ -727,17 +719,17 @@ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
|
||||
// Implements the helper function for {ASSERT|EXPECT}_NE
|
||||
GTEST_IMPL_CMP_HELPER(NE, !=)
|
||||
GTEST_IMPL_CMP_HELPER_(NE, !=)
|
||||
// Implements the helper function for {ASSERT|EXPECT}_LE
|
||||
GTEST_IMPL_CMP_HELPER(LE, <=)
|
||||
GTEST_IMPL_CMP_HELPER_(LE, <=)
|
||||
// Implements the helper function for {ASSERT|EXPECT}_LT
|
||||
GTEST_IMPL_CMP_HELPER(LT, < )
|
||||
GTEST_IMPL_CMP_HELPER_(LT, < )
|
||||
// Implements the helper function for {ASSERT|EXPECT}_GE
|
||||
GTEST_IMPL_CMP_HELPER(GE, >=)
|
||||
GTEST_IMPL_CMP_HELPER_(GE, >=)
|
||||
// Implements the helper function for {ASSERT|EXPECT}_GT
|
||||
GTEST_IMPL_CMP_HELPER(GT, > )
|
||||
GTEST_IMPL_CMP_HELPER_(GT, > )
|
||||
|
||||
#undef GTEST_IMPL_CMP_HELPER
|
||||
#undef GTEST_IMPL_CMP_HELPER_
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STREQ.
|
||||
//
|
||||
@@ -881,7 +873,7 @@ class AssertHelper {
|
||||
AssertHelper(TestPartResultType type, const char* file, int line,
|
||||
const char* message);
|
||||
// Message assignment is a semantic trick to enable assertion
|
||||
// streaming; see the GTEST_MESSAGE macro below.
|
||||
// streaming; see the GTEST_MESSAGE_ macro below.
|
||||
void operator=(const Message& message) const;
|
||||
private:
|
||||
TestPartResultType const type_;
|
||||
@@ -889,7 +881,7 @@ class AssertHelper {
|
||||
int const line_;
|
||||
String const message_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(AssertHelper);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@@ -920,13 +912,13 @@ class AssertHelper {
|
||||
// << "There are still pending requests " << "on port " << port;
|
||||
|
||||
// Generates a nonfatal failure with a generic message.
|
||||
#define ADD_FAILURE() GTEST_NONFATAL_FAILURE("Failed")
|
||||
#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
|
||||
|
||||
// Generates a fatal failure with a generic message.
|
||||
#define FAIL() GTEST_FATAL_FAILURE("Failed")
|
||||
#define FAIL() GTEST_FATAL_FAILURE_("Failed")
|
||||
|
||||
// Generates a success with a generic message.
|
||||
#define SUCCEED() GTEST_SUCCESS("Succeeded")
|
||||
#define SUCCEED() GTEST_SUCCESS_("Succeeded")
|
||||
|
||||
// Macros for testing exceptions.
|
||||
//
|
||||
@@ -938,31 +930,31 @@ class AssertHelper {
|
||||
// Tests that the statement throws an exception.
|
||||
|
||||
#define EXPECT_THROW(statement, expected_exception) \
|
||||
GTEST_TEST_THROW(statement, expected_exception, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_NO_THROW(statement) \
|
||||
GTEST_TEST_NO_THROW(statement, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_ANY_THROW(statement) \
|
||||
GTEST_TEST_ANY_THROW(statement, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_THROW(statement, expected_exception) \
|
||||
GTEST_TEST_THROW(statement, expected_exception, GTEST_FATAL_FAILURE)
|
||||
GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_NO_THROW(statement) \
|
||||
GTEST_TEST_NO_THROW(statement, GTEST_FATAL_FAILURE)
|
||||
GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_ANY_THROW(statement) \
|
||||
GTEST_TEST_ANY_THROW(statement, GTEST_FATAL_FAILURE)
|
||||
GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
|
||||
|
||||
// Boolean assertions.
|
||||
#define EXPECT_TRUE(condition) \
|
||||
GTEST_TEST_BOOLEAN(condition, #condition, false, true, \
|
||||
GTEST_NONFATAL_FAILURE)
|
||||
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||
GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_FALSE(condition) \
|
||||
GTEST_TEST_BOOLEAN(!(condition), #condition, true, false, \
|
||||
GTEST_NONFATAL_FAILURE)
|
||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||
GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_TRUE(condition) \
|
||||
GTEST_TEST_BOOLEAN(condition, #condition, false, true, \
|
||||
GTEST_FATAL_FAILURE)
|
||||
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||
GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_FALSE(condition) \
|
||||
GTEST_TEST_BOOLEAN(!(condition), #condition, true, false, \
|
||||
GTEST_FATAL_FAILURE)
|
||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||
GTEST_FATAL_FAILURE_)
|
||||
|
||||
// Includes the auto-generated header that implements a family of
|
||||
// generic predicate assertion macros.
|
||||
@@ -1016,7 +1008,7 @@ class AssertHelper {
|
||||
|
||||
#define EXPECT_EQ(expected, actual) \
|
||||
EXPECT_PRED_FORMAT2(::testing::internal:: \
|
||||
EqHelper<GTEST_IS_NULL_LITERAL(expected)>::Compare, \
|
||||
EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
|
||||
expected, actual)
|
||||
#define EXPECT_NE(expected, actual) \
|
||||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual)
|
||||
@@ -1031,7 +1023,7 @@ class AssertHelper {
|
||||
|
||||
#define ASSERT_EQ(expected, actual) \
|
||||
ASSERT_PRED_FORMAT2(::testing::internal:: \
|
||||
EqHelper<GTEST_IS_NULL_LITERAL(expected)>::Compare, \
|
||||
EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
|
||||
expected, actual)
|
||||
#define ASSERT_NE(val1, val2) \
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
|
||||
@@ -1154,6 +1146,20 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
// Macros that execute statement and check that it doesn't generate new fatal
|
||||
// failures in the current thread.
|
||||
//
|
||||
// * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// EXPECT_NO_FATAL_FAILURE(Process());
|
||||
// ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
|
||||
//
|
||||
#define ASSERT_NO_FATAL_FAILURE(statement) \
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
|
||||
#define EXPECT_NO_FATAL_FAILURE(statement) \
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Causes a trace (including the source file path, the current line
|
||||
// number, and the given message) to be included in every test failure
|
||||
@@ -1167,7 +1173,7 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
// to appear in the same block - as long as they are on different
|
||||
// lines.
|
||||
#define SCOPED_TRACE(message) \
|
||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN(gtest_trace_, __LINE__)(\
|
||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, ::testing::Message() << (message))
|
||||
|
||||
|
||||
@@ -1188,7 +1194,7 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
// }
|
||||
|
||||
#define TEST(test_case_name, test_name)\
|
||||
GTEST_TEST(test_case_name, test_name, ::testing::Test)
|
||||
GTEST_TEST_(test_case_name, test_name, ::testing::Test)
|
||||
|
||||
|
||||
// Defines a test that uses a test fixture.
|
||||
@@ -1218,7 +1224,7 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
// }
|
||||
|
||||
#define TEST_F(test_fixture, test_name)\
|
||||
GTEST_TEST(test_fixture, test_name, test_fixture)
|
||||
GTEST_TEST_(test_fixture, test_name, test_fixture)
|
||||
|
||||
// Use this macro in main() to run all tests. It returns 0 if all
|
||||
// tests are successful, or 1 otherwise.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on 06/22/2008 by command
|
||||
// This file is AUTOMATICALLY GENERATED on 10/02/2008 by command
|
||||
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// Implements a family of generic predicate assertion macros.
|
||||
@@ -69,11 +69,11 @@
|
||||
// Please email googletestframework@googlegroups.com if you need
|
||||
// support for higher arities.
|
||||
|
||||
// GTEST_ASSERT is the basic statement to which all of the assertions
|
||||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
||||
// in this file reduce. Don't use this in your code.
|
||||
|
||||
#define GTEST_ASSERT(expression, on_failure) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_ASSERT_(expression, on_failure) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::AssertionResult gtest_ar = (expression)) \
|
||||
; \
|
||||
else \
|
||||
@@ -99,27 +99,27 @@ AssertionResult AssertPred1Helper(const char* pred_text,
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT1(pred_format, v1, on_failure)\
|
||||
GTEST_ASSERT(pred_format(#v1, v1),\
|
||||
on_failure)
|
||||
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, v1),\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED1(pred, v1, on_failure)\
|
||||
GTEST_ASSERT(::testing::AssertPred1Helper(#pred, \
|
||||
#v1, \
|
||||
pred, \
|
||||
v1), on_failure)
|
||||
#define GTEST_PRED1_(pred, v1, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
|
||||
#v1, \
|
||||
pred, \
|
||||
v1), on_failure)
|
||||
|
||||
// Unary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT1(pred_format, v1) \
|
||||
GTEST_PRED_FORMAT1(pred_format, v1, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED1(pred, v1) \
|
||||
GTEST_PRED1(pred, v1, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT1(pred_format, v1) \
|
||||
GTEST_PRED_FORMAT1(pred_format, v1, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED1(pred, v1) \
|
||||
GTEST_PRED1(pred, v1, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
@@ -147,29 +147,29 @@ AssertionResult AssertPred2Helper(const char* pred_text,
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT2(pred_format, v1, v2, on_failure)\
|
||||
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2),\
|
||||
on_failure)
|
||||
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED2(pred, v1, v2, on_failure)\
|
||||
GTEST_ASSERT(::testing::AssertPred2Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2), on_failure)
|
||||
#define GTEST_PRED2_(pred, v1, v2, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2), on_failure)
|
||||
|
||||
// Binary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
|
||||
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED2(pred, v1, v2) \
|
||||
GTEST_PRED2(pred, v1, v2, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
|
||||
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED2(pred, v1, v2) \
|
||||
GTEST_PRED2(pred, v1, v2, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
@@ -202,31 +202,31 @@ AssertionResult AssertPred3Helper(const char* pred_text,
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT3(pred_format, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT(pred_format(#v1, #v2, #v3, v1, v2, v3),\
|
||||
on_failure)
|
||||
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3),\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED3(pred, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT(::testing::AssertPred3Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3), on_failure)
|
||||
#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3), on_failure)
|
||||
|
||||
// Ternary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
|
||||
GTEST_PRED_FORMAT3(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED3(pred, v1, v2, v3) \
|
||||
GTEST_PRED3(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
|
||||
GTEST_PRED_FORMAT3(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED3(pred, v1, v2, v3) \
|
||||
GTEST_PRED3(pred, v1, v2, v3, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
@@ -264,33 +264,33 @@ AssertionResult AssertPred4Helper(const char* pred_text,
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT4(pred_format, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
|
||||
on_failure)
|
||||
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED4(pred, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT(::testing::AssertPred4Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4), on_failure)
|
||||
#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4), on_failure)
|
||||
|
||||
// 4-ary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
|
||||
GTEST_PRED_FORMAT4(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
|
||||
GTEST_PRED4(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
|
||||
GTEST_PRED_FORMAT4(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
|
||||
GTEST_PRED4(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
@@ -333,35 +333,35 @@ AssertionResult AssertPred5Helper(const char* pred_text,
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
|
||||
on_failure)
|
||||
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED5(pred, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT(::testing::AssertPred5Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
#v5, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4, \
|
||||
v5), on_failure)
|
||||
#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
#v5, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4, \
|
||||
v5), on_failure)
|
||||
|
||||
// 5-ary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
|
||||
GTEST_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
|
||||
GTEST_PRED5(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE)
|
||||
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
|
||||
GTEST_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
|
||||
GTEST_PRED5(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE)
|
||||
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
||||
GTEST_DECLARE_string(internal_run_death_test);
|
||||
GTEST_DECLARE_string_(internal_run_death_test);
|
||||
|
||||
// Names of the flags (needed for parsing Google Test flags).
|
||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
||||
@@ -51,7 +51,7 @@ const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
|
||||
// DeathTest is a class that hides much of the complexity of the
|
||||
// GTEST_DEATH_TEST macro. It is abstract; its static Create method
|
||||
// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
|
||||
// returns a concrete class that depends on the prevailing death test
|
||||
// style, as defined by the --gtest_death_test_style and/or
|
||||
// --gtest_internal_run_death_test flags.
|
||||
@@ -85,8 +85,8 @@ class DeathTest {
|
||||
~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
|
||||
private:
|
||||
DeathTest* const test_;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(ReturnSentinel);
|
||||
} GTEST_ATTRIBUTE_UNUSED;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
|
||||
} GTEST_ATTRIBUTE_UNUSED_;
|
||||
|
||||
// An enumeration of possible roles that may be taken when a death
|
||||
// test is encountered. EXECUTE means that the death test logic should
|
||||
@@ -121,7 +121,7 @@ class DeathTest {
|
||||
static const char* LastMessage();
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(DeathTest);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
|
||||
};
|
||||
|
||||
// Factory interface for death tests. May be mocked out for testing.
|
||||
@@ -145,14 +145,14 @@ bool ExitedUnsuccessfully(int exit_status);
|
||||
|
||||
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
||||
// ASSERT_EXIT*, and EXPECT_EXIT*.
|
||||
#define GTEST_DEATH_TEST(statement, predicate, regex, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (true) { \
|
||||
const ::testing::internal::RE& gtest_regex = (regex); \
|
||||
::testing::internal::DeathTest* gtest_dt; \
|
||||
if (!::testing::internal::DeathTest::Create(#statement, >est_regex, \
|
||||
__FILE__, __LINE__, >est_dt)) { \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
|
||||
} \
|
||||
if (gtest_dt != NULL) { \
|
||||
::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
|
||||
@@ -160,7 +160,7 @@ bool ExitedUnsuccessfully(int exit_status);
|
||||
switch (gtest_dt->AssumeRole()) { \
|
||||
case ::testing::internal::DeathTest::OVERSEE_TEST: \
|
||||
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
|
||||
} \
|
||||
break; \
|
||||
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
|
||||
@@ -173,7 +173,7 @@ bool ExitedUnsuccessfully(int exit_status);
|
||||
} \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN(gtest_label_, __LINE__): \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
|
||||
fail(::testing::internal::DeathTest::LastMessage())
|
||||
// The symbol "fail" here expands to something into which a message
|
||||
// can be streamed.
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
// will result in the token foo__LINE__, instead of foo followed by
|
||||
// the current line number. For more details, see
|
||||
// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
|
||||
#define GTEST_CONCAT_TOKEN(foo, bar) GTEST_CONCAT_TOKEN_IMPL(foo, bar)
|
||||
#define GTEST_CONCAT_TOKEN_IMPL(foo, bar) foo ## bar
|
||||
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
|
||||
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
|
||||
|
||||
// Google Test defines the testing::Message class to allow construction of
|
||||
// test messages via the << operator. The idea is that anything
|
||||
@@ -121,6 +121,10 @@ class UnitTestImpl; // Opaque implementation of UnitTest
|
||||
template <typename E> class List; // A generic list.
|
||||
template <typename E> class ListNode; // A node in a generic list.
|
||||
|
||||
// The text used in failure messages to indicate the start of the
|
||||
// stack trace.
|
||||
extern const char kStackTraceMarker[];
|
||||
|
||||
// A secret type that Google Test users don't know about. It has no
|
||||
// definition on purpose. Therefore it's impossible to create a
|
||||
// Secret object, which is what we want.
|
||||
@@ -151,11 +155,11 @@ char (&IsNullLiteralHelper(...))[2]; // NOLINT
|
||||
// The Nokia Symbian compiler tries to instantiate a copy constructor for
|
||||
// objects passed through ellipsis (...), failing for uncopyable objects.
|
||||
// Hence we define this to false (and lose support for NULL detection).
|
||||
#define GTEST_IS_NULL_LITERAL(x) false
|
||||
#else // ! __SYMBIAN32__
|
||||
#define GTEST_IS_NULL_LITERAL(x) \
|
||||
#define GTEST_IS_NULL_LITERAL_(x) false
|
||||
#else // ! GTEST_OS_SYMBIAN
|
||||
#define GTEST_IS_NULL_LITERAL_(x) \
|
||||
(sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
|
||||
#endif // __SYMBIAN32__
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// Appends the user-supplied message to the Google-Test-generated message.
|
||||
String AppendUserMessage(const String& gtest_msg,
|
||||
@@ -175,10 +179,10 @@ class ScopedTrace {
|
||||
~ScopedTrace();
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
|
||||
} GTEST_ATTRIBUTE_UNUSED; // A ScopedTrace object does its job in its
|
||||
// c'tor and d'tor. Therefore it doesn't
|
||||
// need to be used otherwise.
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
|
||||
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
|
||||
// c'tor and d'tor. Therefore it doesn't
|
||||
// need to be used otherwise.
|
||||
|
||||
// Converts a streamable value to a String. A NULL pointer is
|
||||
// converted to "(null)". When the input value is a ::string,
|
||||
@@ -192,7 +196,7 @@ String StreamableToString(const T& streamable);
|
||||
|
||||
// Formats a value to be used in a failure message.
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#ifdef GTEST_OS_SYMBIAN
|
||||
|
||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
||||
@@ -233,7 +237,7 @@ inline String FormatForFailureMessage(T* pointer) {
|
||||
return StreamableToString(static_cast<const void*>(pointer));
|
||||
}
|
||||
|
||||
#endif // __SYMBIAN32__
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// These overloaded versions handle narrow and wide characters.
|
||||
String FormatForFailureMessage(char ch);
|
||||
@@ -244,7 +248,7 @@ String FormatForFailureMessage(wchar_t wchar);
|
||||
// rather than a pointer. We do the same for wide strings.
|
||||
|
||||
// This internal macro is used to avoid duplicated code.
|
||||
#define GTEST_FORMAT_IMPL(operand2_type, operand1_printer)\
|
||||
#define GTEST_FORMAT_IMPL_(operand2_type, operand1_printer)\
|
||||
inline String FormatForComparisonFailureMessage(\
|
||||
operand2_type::value_type* str, const operand2_type& /*operand2*/) {\
|
||||
return operand1_printer(str);\
|
||||
@@ -255,20 +259,20 @@ inline String FormatForComparisonFailureMessage(\
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
GTEST_FORMAT_IMPL(::std::string, String::ShowCStringQuoted)
|
||||
GTEST_FORMAT_IMPL_(::std::string, String::ShowCStringQuoted)
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
GTEST_FORMAT_IMPL(::std::wstring, String::ShowWideCStringQuoted)
|
||||
GTEST_FORMAT_IMPL_(::std::wstring, String::ShowWideCStringQuoted)
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
#if GTEST_HAS_GLOBAL_STRING
|
||||
GTEST_FORMAT_IMPL(::string, String::ShowCStringQuoted)
|
||||
GTEST_FORMAT_IMPL_(::string, String::ShowCStringQuoted)
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
GTEST_FORMAT_IMPL(::wstring, String::ShowWideCStringQuoted)
|
||||
GTEST_FORMAT_IMPL_(::wstring, String::ShowWideCStringQuoted)
|
||||
#endif // GTEST_HAS_GLOBAL_WSTRING
|
||||
|
||||
#undef GTEST_FORMAT_IMPL
|
||||
#undef GTEST_FORMAT_IMPL_
|
||||
|
||||
// Constructs and returns the message for an equality assertion
|
||||
// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
|
||||
@@ -503,7 +507,7 @@ class TestFactoryBase {
|
||||
TestFactoryBase() {}
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(TestFactoryBase);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
|
||||
};
|
||||
|
||||
// This class provides implementation of TeastFactoryBase interface.
|
||||
@@ -704,22 +708,22 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
|
||||
#define GTEST_MESSAGE(message, result_type) \
|
||||
#define GTEST_MESSAGE_(message, result_type) \
|
||||
::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, message) \
|
||||
= ::testing::Message()
|
||||
|
||||
#define GTEST_FATAL_FAILURE(message) \
|
||||
return GTEST_MESSAGE(message, ::testing::TPRT_FATAL_FAILURE)
|
||||
#define GTEST_FATAL_FAILURE_(message) \
|
||||
return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE)
|
||||
|
||||
#define GTEST_NONFATAL_FAILURE(message) \
|
||||
GTEST_MESSAGE(message, ::testing::TPRT_NONFATAL_FAILURE)
|
||||
#define GTEST_NONFATAL_FAILURE_(message) \
|
||||
GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE)
|
||||
|
||||
#define GTEST_SUCCESS(message) \
|
||||
GTEST_MESSAGE(message, ::testing::TPRT_SUCCESS)
|
||||
#define GTEST_SUCCESS_(message) \
|
||||
GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS)
|
||||
|
||||
|
||||
#define GTEST_TEST_THROW(statement, expected_exception, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
bool gtest_caught_expected = false; \
|
||||
try { \
|
||||
@@ -732,19 +736,19 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
||||
gtest_msg = "Expected: " #statement " throws an exception of type " \
|
||||
#expected_exception ".\n Actual: it throws a different " \
|
||||
"type."; \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_testthrow_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
||||
} \
|
||||
if (!gtest_caught_expected) { \
|
||||
gtest_msg = "Expected: " #statement " throws an exception of type " \
|
||||
#expected_exception ".\n Actual: it throws nothing."; \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_testthrow_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN(gtest_label_testthrow_, __LINE__): \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#define GTEST_TEST_NO_THROW(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
try { \
|
||||
statement; \
|
||||
@@ -752,14 +756,14 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
||||
catch (...) { \
|
||||
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
|
||||
" Actual: it throws."; \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_testnothrow_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN(gtest_label_testnothrow_, __LINE__): \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#define GTEST_TEST_ANY_THROW(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
bool gtest_caught_any = false; \
|
||||
try { \
|
||||
@@ -771,33 +775,48 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
||||
if (!gtest_caught_any) { \
|
||||
gtest_msg = "Expected: " #statement " throws an exception.\n" \
|
||||
" Actual: it doesn't."; \
|
||||
goto GTEST_CONCAT_TOKEN(gtest_label_testanythrow_, __LINE__); \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN(gtest_label_testanythrow_, __LINE__): \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
|
||||
#define GTEST_TEST_BOOLEAN(boolexpr, booltext, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER \
|
||||
#define GTEST_TEST_BOOLEAN_(boolexpr, booltext, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (boolexpr) \
|
||||
; \
|
||||
else \
|
||||
fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expected)
|
||||
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
|
||||
{ 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" \
|
||||
" Actual: it does."; \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
// Expands to the name of the class that implements the given test.
|
||||
#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
||||
test_case_name##_##test_name##_Test
|
||||
|
||||
// Helper macro for defining tests.
|
||||
#define GTEST_TEST(test_case_name, test_name, parent_class)\
|
||||
#define GTEST_TEST_(test_case_name, test_name, parent_class)\
|
||||
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
|
||||
public:\
|
||||
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
|
||||
private:\
|
||||
virtual void TestBody();\
|
||||
static ::testing::TestInfo* const test_info_;\
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(\
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
|
||||
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
|
||||
};\
|
||||
\
|
||||
|
||||
@@ -37,27 +37,25 @@
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
|
||||
// The user can define the following macros in the build script to
|
||||
// control Google Test's behavior:
|
||||
// control Google Test's behavior. If the user doesn't define a macro
|
||||
// in this list, Google Test will define it.
|
||||
//
|
||||
// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
|
||||
// std::string does/doesn't work (Google Test can
|
||||
// be used where std::string is unavailable).
|
||||
// Leave it undefined to let Google Test define it.
|
||||
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
|
||||
// is/isn't available (some systems define
|
||||
// ::string, which is different to std::string).
|
||||
// Leave it undefined to let Google Test define it.
|
||||
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
|
||||
// std::wstring does/doesn't work (Google Test can
|
||||
// be used where std::wstring is unavailable).
|
||||
// Leave it undefined to let Google Test define it.
|
||||
// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
|
||||
// is/isn't available (some systems define
|
||||
// ::wstring, which is different to std::wstring).
|
||||
// Leave it undefined to let Google Test define it.
|
||||
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
|
||||
// enabled. Leave it undefined to let Google
|
||||
// Test define it.
|
||||
// enabled.
|
||||
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
|
||||
// is/isn't available.
|
||||
|
||||
// This header defines the following utilities:
|
||||
//
|
||||
@@ -72,6 +70,7 @@
|
||||
// GTEST_OS_CYGWIN - defined iff compiled on Cygwin.
|
||||
// GTEST_OS_LINUX - defined iff compiled on Linux.
|
||||
// GTEST_OS_MAC - defined iff compiled on Mac OS X.
|
||||
// GTEST_OS_SYMBIAN - defined iff compiled for Symbian.
|
||||
// GTEST_OS_WINDOWS - defined iff compiled on Windows.
|
||||
// Note that it is possible that none of the GTEST_OS_ macros are defined.
|
||||
//
|
||||
@@ -82,15 +81,18 @@
|
||||
// supported.
|
||||
//
|
||||
// Macros for basic C++ coding:
|
||||
// GTEST_AMBIGUOUS_ELSE_BLOCKER - for disabling a gcc warning.
|
||||
// GTEST_ATTRIBUTE_UNUSED - declares that a class' instances don't have to
|
||||
// be used.
|
||||
// GTEST_DISALLOW_COPY_AND_ASSIGN() - disables copy ctor and operator=.
|
||||
// GTEST_MUST_USE_RESULT - declares that a function's result must be used.
|
||||
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
|
||||
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances don't have to
|
||||
// be used.
|
||||
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
|
||||
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
|
||||
//
|
||||
// Synchronization:
|
||||
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
|
||||
// - synchronization primitives.
|
||||
// GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
|
||||
// synchronization primitives have real implementations
|
||||
// and Google Test is thread-safe; or 0 otherwise.
|
||||
//
|
||||
// Template meta programming:
|
||||
// is_pointer - as in TR1; needed on Symbian only.
|
||||
@@ -104,7 +106,7 @@
|
||||
// Windows.
|
||||
//
|
||||
// Logging:
|
||||
// GTEST_LOG() - logs messages at the specified severity level.
|
||||
// GTEST_LOG_() - logs messages at the specified severity level.
|
||||
// LogToStderr() - directs all log messages to stderr.
|
||||
// FlushInfoLog() - flushes informational log messages.
|
||||
//
|
||||
@@ -148,6 +150,8 @@
|
||||
// Determines the platform on which Google Test is compiled.
|
||||
#ifdef __CYGWIN__
|
||||
#define GTEST_OS_CYGWIN
|
||||
#elif __SYMBIAN32__
|
||||
#define GTEST_OS_SYMBIAN
|
||||
#elif defined _MSC_VER
|
||||
// TODO(kenton@google.com): GTEST_OS_WINDOWS is currently used to mean
|
||||
// both "The OS is Windows" and "The compiler is MSVC". These
|
||||
@@ -261,6 +265,18 @@
|
||||
|
||||
#endif // GTEST_HAS_RTTI
|
||||
|
||||
// Determines whether <pthread.h> is available.
|
||||
#ifndef GTEST_HAS_PTHREAD
|
||||
// The user didn't tell us, so we need to figure it out.
|
||||
|
||||
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC)
|
||||
#define GTEST_HAS_PTHREAD 1
|
||||
#else
|
||||
#define GTEST_HAS_PTHREAD 0
|
||||
#endif // GTEST_OS_LINUX || GTEST_OS_MAC
|
||||
|
||||
#endif // GTEST_HAS_PTHREAD
|
||||
|
||||
// Determines whether to support death tests.
|
||||
#if GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
|
||||
#define GTEST_HAS_DEATH_TEST
|
||||
@@ -285,7 +301,7 @@
|
||||
|
||||
// Determines whether the system compiler uses UTF-16 for encoding wide strings.
|
||||
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_CYGWIN) || \
|
||||
defined(__SYMBIAN32__)
|
||||
defined(GTEST_OS_SYMBIAN)
|
||||
#define GTEST_WIDE_STRING_USES_UTF16_ 1
|
||||
#endif
|
||||
|
||||
@@ -300,9 +316,9 @@
|
||||
//
|
||||
// The "switch (0) case 0:" idiom is used to suppress this.
|
||||
#ifdef __INTEL_COMPILER
|
||||
#define GTEST_AMBIGUOUS_ELSE_BLOCKER
|
||||
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_
|
||||
#else
|
||||
#define GTEST_AMBIGUOUS_ELSE_BLOCKER switch (0) case 0: // NOLINT
|
||||
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: // NOLINT
|
||||
#endif
|
||||
|
||||
// Use this annotation at the end of a struct / class definition to
|
||||
@@ -312,16 +328,16 @@
|
||||
//
|
||||
// struct Foo {
|
||||
// Foo() { ... }
|
||||
// } GTEST_ATTRIBUTE_UNUSED;
|
||||
// } GTEST_ATTRIBUTE_UNUSED_;
|
||||
#if defined(__GNUC__) && !defined(COMPILER_ICC)
|
||||
#define GTEST_ATTRIBUTE_UNUSED __attribute__ ((unused))
|
||||
#define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
|
||||
#else
|
||||
#define GTEST_ATTRIBUTE_UNUSED
|
||||
#define GTEST_ATTRIBUTE_UNUSED_
|
||||
#endif
|
||||
|
||||
// A macro to disallow the evil copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class.
|
||||
#define GTEST_DISALLOW_COPY_AND_ASSIGN(type)\
|
||||
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
|
||||
type(const type &);\
|
||||
void operator=(const type &)
|
||||
|
||||
@@ -329,11 +345,11 @@
|
||||
// with this macro. The macro should be used on function declarations
|
||||
// following the argument list:
|
||||
//
|
||||
// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT;
|
||||
// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
|
||||
#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
|
||||
#define GTEST_MUST_USE_RESULT __attribute__ ((warn_unused_result))
|
||||
#define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
|
||||
#else
|
||||
#define GTEST_MUST_USE_RESULT
|
||||
#define GTEST_MUST_USE_RESULT_
|
||||
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
|
||||
|
||||
namespace testing {
|
||||
@@ -385,7 +401,7 @@ class scoped_ptr {
|
||||
private:
|
||||
T* ptr_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN(scoped_ptr);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
|
||||
};
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
@@ -444,7 +460,7 @@ class RE {
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
// Defines logging utilities:
|
||||
// GTEST_LOG() - logs messages at the specified severity level.
|
||||
// GTEST_LOG_() - logs messages at the specified severity level.
|
||||
// LogToStderr() - directs all log messages to stderr.
|
||||
// FlushInfoLog() - flushes informational log messages.
|
||||
|
||||
@@ -458,7 +474,7 @@ enum GTestLogSeverity {
|
||||
void GTestLog(GTestLogSeverity severity, const char* file,
|
||||
int line, const char* msg);
|
||||
|
||||
#define GTEST_LOG(severity, msg)\
|
||||
#define GTEST_LOG_(severity, msg)\
|
||||
::testing::internal::GTestLog(\
|
||||
::testing::internal::GTEST_##severity, __FILE__, __LINE__, \
|
||||
(::testing::Message() << (msg)).GetString().c_str())
|
||||
@@ -510,6 +526,8 @@ typedef GTestMutexLock MutexLock;
|
||||
template <typename T>
|
||||
class ThreadLocal {
|
||||
public:
|
||||
ThreadLocal() : value_() {}
|
||||
explicit ThreadLocal(const T& value) : value_(value) {}
|
||||
T* pointer() { return &value_; }
|
||||
const T* pointer() const { return &value_; }
|
||||
const T& get() const { return value_; }
|
||||
@@ -522,6 +540,10 @@ class ThreadLocal {
|
||||
// return 0 to indicate that we cannot detect it.
|
||||
inline size_t GetThreadCount() { return 0; }
|
||||
|
||||
// The above synchronization primitives have dummy implementations.
|
||||
// Therefore Google Test is not thread-safe.
|
||||
#define GTEST_IS_THREADSAFE 0
|
||||
|
||||
// Defines tr1::is_pointer (only needed for Symbian).
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
@@ -657,18 +679,18 @@ inline void abort() { ::abort(); }
|
||||
#define GTEST_FLAG(name) FLAGS_gtest_##name
|
||||
|
||||
// Macros for declaring flags.
|
||||
#define GTEST_DECLARE_bool(name) extern bool GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_int32(name) \
|
||||
#define GTEST_DECLARE_bool_(name) extern bool GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_int32_(name) \
|
||||
extern ::testing::internal::Int32 GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_string(name) \
|
||||
#define GTEST_DECLARE_string_(name) \
|
||||
extern ::testing::internal::String GTEST_FLAG(name)
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool(name, default_val, doc) \
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
bool GTEST_FLAG(name) = (default_val)
|
||||
#define GTEST_DEFINE_int32(name, default_val, doc) \
|
||||
#define GTEST_DEFINE_int32_(name, default_val, doc) \
|
||||
::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
||||
#define GTEST_DEFINE_string(name, default_val, doc) \
|
||||
#define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||
::testing::internal::String GTEST_FLAG(name) = (default_val)
|
||||
|
||||
// Parses 'str' for a 32-bit signed integer. If successful, writes the result
|
||||
|
||||
Reference in New Issue
Block a user