aboutsummaryrefslogtreecommitdiffstats
path: root/include/gtest
diff options
context:
space:
mode:
Diffstat (limited to 'include/gtest')
-rw-r--r--include/gtest/gtest-death-test.h6
-rw-r--r--include/gtest/gtest-message.h8
-rw-r--r--include/gtest/gtest-spi.h226
-rw-r--r--include/gtest/gtest-test-part.h179
-rw-r--r--include/gtest/gtest.h98
-rw-r--r--include/gtest/gtest_pred_impl.h168
-rw-r--r--include/gtest/internal/gtest-death-test-internal.h20
-rw-r--r--include/gtest/internal/gtest-internal.h105
-rw-r--r--include/gtest/internal/gtest-port.h86
9 files changed, 551 insertions, 345 deletions
diff --git a/include/gtest/gtest-death-test.h b/include/gtest/gtest-death-test.h
index 6fae47fb..f0e109a3 100644
--- a/include/gtest/gtest-death-test.h
+++ b/include/gtest/gtest-death-test.h
@@ -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
diff --git a/include/gtest/gtest-message.h b/include/gtest/gtest-message.h
index b1d646f0..7effd086 100644
--- a/include/gtest/gtest-message.h
+++ b/include/gtest/gtest-message.h
@@ -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_;
diff --git a/include/gtest/gtest-spi.h b/include/gtest/gtest-spi.h
index 5315b97d..90acfbcb 100644
--- a/include/gtest/gtest-spi.h
+++ b/include/gtest/gtest-spi.h
@@ -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(\
+ &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
+ {\
+ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+ intercept_mode, &gtest_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 {
&gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
- &gtest_failures);\
+ ::testing::ScopedFakeTestPartResultReporter:: \
+ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_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(\
+ &gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
+ {\
+ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+ ::testing::ScopedFakeTestPartResultReporter:: \
+ INTERCEPT_ALL_THREADS, &gtest_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(\
+ &gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
+ {\
+ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+ ::testing::ScopedFakeTestPartResultReporter:: \
+ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
+ statement;\
+ }\
+ } while (false)
+
+#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));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
+ ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
&gtest_failures);\
return __bootloader.get_boot_policies() def add_boot_policy(index, binpolname): """ See description in Bootloader class below """ return __bootloader.add_boot_policy(index, binpolname) def rm_policy_from_boottitle(index, unamelist): """ See description in Bootloader class below """ return __bootloader.rm_policy_from_boottitle(index, unamelist) def set_kernel_attval(index, att, val): """ See description in Bootloader class below """ return __bootloader.set_kernel_attval(index, att, val) def get_kernel_val(index, att): """ See description in Bootloader class below """ return __bootloader.get_kernel_val(index, att) def set_boot_policy(title_idx, filename): boottitles = get_boot_policies() for key in boottitles.iterkeys(): boottitles[key] += ".bin" if boottitles.has_key(title_idx): rm_policy_from_boottitle(title_idx, [ boottitles[title_idx] ]) rc = add_boot_policy(title_idx, filename) return rc def loads_default_policy(filename): """ Determine whether the given policy is loaded by the default boot title """ policy = get_default_policy() if policy: polfile = policy + ".bin" if polfile == filename or \ "/"+polfile == filename: return True return False def get_default_policy(): """ Get the name of the policy loaded by the default boot title """ title = get_default_title() policies = get_boot_policies() return policies.get(title) def set_default_boot_policy(filename): """ Set the boot policy in the default title to the given name. """ title = get_default_title() return set_boot_policy(title, filename) def __is_bootdir_mounted(): """ Determine whether the boot partition /boot is mounted or not """ rc = False file = open("/proc/mounts") for line in file: tmp = line.split(" ") if tmp[1] == "/boot": rc = True break return rc def get_prefix(): if __is_bootdir_mounted(): return "/" else: return "/boot/" class Bootloader: """ Bootloader class that real bootloader implementations must overwrite """ def __init__(self): pass def probe(self): """ Test whether this implementation of a bootloader is supported on the local system """ return True def get_default_title(self): """ Get the index (starting with 0) of the default boot title This number is read from the grub configuration file. In case of an error '-1' is returned @rtype: int @return: the index of the default boot title """ return None def get_boot_policies(self): """ Get a dictionary of policies that the system is booting with. @rtype: dict @return: dictionary of boot titles where the keys are the indices of the boot titles """ return {} def add_boot_policy(self, index, binpolname): """ Add the binary policy for automatic loading when booting the system. Add it to the boot title at index 'index'. """ return False def rm_policy_from_boottitle(self, index, unamelist): """ Remove a policy from the given title. A list of possible policies must be given to detect what module to remove """ return False def set_kernel_attval(self, index, att, val): """ Append an attribut/value pair to the kernel line. @param index : The index of the title to modify @param att : The attribute to add @param val : The value to add. If no value or the special value '<>' is given, then the attribute will be removed. If an empty value is given, then only the attribute is added in the format "att", otherwise "att=val" is added. """ return False def get_kernel_val(self, index, att): """ Get an attribute's value from the kernel line. @param index : The index of the title to get the attribute/value from @param att : The attribute to read the value of """ return None class Grub(Bootloader): """ Implementation for manipulating bootloader entries in grub according to the 'Bootloader' class interface """ def __init__(self): self.__bootfile_lock = threading.RLock() self.title_re = re.compile("\s*title\s", re.IGNORECASE) self.module_re = re.compile("\s+module\s", re.IGNORECASE) self.policy_re = re.compile(".*\.bin", re.IGNORECASE) self.kernel_re = re.compile("\s*kernel\s", re.IGNORECASE) Bootloader.__init__(self) def probe(self): try: boot_file = self.__get_bootfile() except: return False return True def __get_bootfile(self): """ Get the name of the bootfile """ boot_file = "/boot/grub/grub.conf" alt_boot_file = "/boot/grub/menu.lst" if not os.path.isfile(boot_file): #take alternate boot file instead boot_file = alt_boot_file #follow symlink since menue.lst might be linked to grub.conf if not os.path.exists(boot_file): raise IOError("Boot file \'%s\' not found." % boot_file) if stat.S_ISLNK(os.lstat(boot_file)[stat.ST_MODE]): new_name = os.readlink(boot_file) if new_name[0] == "/": boot_file = new_name else: path = boot_file.split('/') path[len(path)-1] = new_name boot_file = '/'.join(path) if not os.path.exists(boot_file): raise IOError("Boot file \'%s\' not found." % boot_file) return boot_file def get_default_title(self): """ Get the index (starting with 0) of the default boot title This number is read from the grub configuration file. In case of an error '-1' is returned @rtype: int @return: the index of the default boot title """ def_re = re.compile("default", re.IGNORECASE) default = None try: boot_file = self.__get_bootfile() except: return default try: self.__bootfile_lock.acquire() grub_fd = open(boot_file) for line in grub_fd: line = line.rstrip() if def_re.match(line): #remove 'default=' line = line.lstrip()[8:] default = int(line) break finally: self.__bootfile_lock.release() return default def get_boot_policies(self): """ Get a dictionary of policies that the system is booting with. @rtype: dict @return: dictionary of boot titles where the keys are the indices of the boot titles """ policies = {} within_title = 0 idx = -1 nal::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.
diff --git a/include/gtest/gtest_pred_impl.h b/include/gtest/gtest_pred_impl.h
index 984f7930..e1e2f8c4 100644
--- a/include/gtest/gtest_pred_impl.h
+++ b/include/gtest/gtest_pred_impl.h
@@ -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_)
diff --git a/include/gtest/internal/gtest-death-test-internal.h b/include/gtest/internal/gtest-death-test-internal.h
index b49c6e47..0769fcaa 100644
--- a/include/gtest/internal/gtest-death-test-internal.h
+++ b/include/gtest/internal/gtest-death-test-internal.h
@@ -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, &gtest_regex, \
__FILE__, __LINE__, &gtest_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.
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index 898047e8..7128a51d 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -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));\
};\
\
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index 022e6706..1363b2c3 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -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