Merge gtest-1.4.0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2010-06-02 22:02:11 +00:00
parent e4b9c93fc1
commit 190f8ee25a
21 changed files with 4154 additions and 2056 deletions

View File

@@ -39,24 +39,24 @@
namespace testing {
// The possible outcomes of a test part (i.e. an assertion or an
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
enum TestPartResultType {
TPRT_SUCCESS, // Succeeded.
TPRT_NONFATAL_FAILURE, // Failed but the test can continue.
TPRT_FATAL_FAILURE // Failed and the test should be terminated.
};
// A copyable object representing the result of a test part (i.e. an
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
//
// Don't inherit from TestPartResult as its destructor is not virtual.
class TestPartResult {
public:
// The possible outcomes of a test part (i.e. an assertion or an
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
enum Type {
kSuccess, // Succeeded.
kNonFatalFailure, // Failed but the test can continue.
kFatalFailure // Failed and the test should be terminated.
};
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestPartResult object.
TestPartResult(TestPartResultType type,
TestPartResult(Type type,
const char* file_name,
int line_number,
const char* message)
@@ -68,7 +68,7 @@ class TestPartResult {
}
// Gets the outcome of the test part.
TestPartResultType type() const { return type_; }
Type type() const { return type_; }
// Gets the name of the source file where the test part took place, or
// NULL if it's unknown.
@@ -85,18 +85,18 @@ class TestPartResult {
const char* message() const { return message_.c_str(); }
// Returns true iff the test part passed.
bool passed() const { return type_ == TPRT_SUCCESS; }
bool passed() const { return type_ == kSuccess; }
// Returns true iff the test part failed.
bool failed() const { return type_ != TPRT_SUCCESS; }
bool failed() const { return type_ != kSuccess; }
// Returns true iff the test part non-fatally failed.
bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; }
bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
// Returns true iff the test part fatally failed.
bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; }
bool fatally_failed() const { return type_ == kFatalFailure; }
private:
TestPartResultType type_;
Type type_;
// Gets the summary of the failure message by omitting the stack
// trace in it.
@@ -136,9 +136,8 @@ class TestPartResultArray {
// 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_;
// Internally we use a Vector to implement the array.
internal::Vector<TestPartResult>* const array_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
};