mirror of
https://github.com/google/googletest.git
synced 2025-04-08 06:43:10 +00:00
Applies the VC 6 port patch by Koji Yoshioka.
This commit is contained in:
parent
d20ebb2c2e
commit
012964e55b
15 changed files with 1349 additions and 96 deletions
|
@ -109,6 +109,14 @@ class Message {
|
|||
StreamHelper(typename internal::is_pointer<T>::type(), value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
template <typename T>
|
||||
inline Message& operator <<(const T& value) {
|
||||
internal::is_pointer<T>::type b;
|
||||
StreamHelper(b, value);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
// Streams a non-pointer value to this object.
|
||||
template <typename T>
|
||||
|
@ -154,7 +162,8 @@ class Message {
|
|||
|
||||
// Instead of 1/0, we want to see true/false for bool values.
|
||||
Message& operator <<(bool b) {
|
||||
return *this << (b ? "true" : "false");
|
||||
*ss_ << (b ? "true" : "false");
|
||||
return *this;
|
||||
}
|
||||
|
||||
// These two overloads allow streaming a wide C string to a Message
|
||||
|
@ -204,6 +213,21 @@ class Message {
|
|||
inline void StreamHelper(internal::false_type dummy, const T& value) {
|
||||
::GTestStreamToHelper(ss_, value);
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
template <typename T>
|
||||
inline void StreamHelper(internal::true_type dummy, T* pointer) {
|
||||
if (pointer == NULL) {
|
||||
*ss_ << "(null)";
|
||||
} else {
|
||||
::GTestStreamToHelper(ss_, pointer);
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
inline void StreamHelper(internal::false_type dummy, const T& value) {
|
||||
::GTestStreamToHelper(ss_, value);
|
||||
}
|
||||
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// We'll hold the text streamed to this object here.
|
||||
|
|
|
@ -548,9 +548,14 @@ class UnitTest {
|
|||
// Creates an empty UnitTest.
|
||||
UnitTest();
|
||||
|
||||
|
||||
// D'tor
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
||||
public:
|
||||
#endif
|
||||
virtual ~UnitTest();
|
||||
|
||||
private:
|
||||
// Pushes a trace defined by SCOPED_TRACE() on to the per-thread
|
||||
// Google Test trace stack.
|
||||
void PushGTestTrace(const internal::TraceInfo& trace);
|
||||
|
@ -1193,6 +1198,56 @@ const T* TestWithParam<T>::parameter_ = NULL;
|
|||
#define ASSERT_STRCASENE(s1, s2)\
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// MSVC6's preprocessor can't stringize some string literal which include
|
||||
// escape sequence(like "\"\"").
|
||||
// so EXPECT_STRXXX and ASSERT_STRXX don't compile for some cases like below,
|
||||
//
|
||||
// std::string twoDoubleQuates = std::string("\"") + std::string("\"");
|
||||
// EXPECT_STREQ("\"\"", twoDoubleQuates.c_str()); // compile error!
|
||||
//
|
||||
// if you should support MSVC6, it's better to use
|
||||
// (EXPECT|ASSERT)_STRXX_USE_ESCAPED in these cases.
|
||||
// XX_USE_ESCAPED does not use stringize(#). Failure message will be poor,
|
||||
// but it does work.
|
||||
#define EXPECT_STREQ_USE_ESCAPED(expected, actual) \
|
||||
EXPECT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTREQ, \
|
||||
expected, actual)
|
||||
#define EXPECT_STRNE_USE_ESCAPED(s1, s2) \
|
||||
EXPECT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRNE, s1, s2)
|
||||
#define EXPECT_STRCASEEQ_USE_ESCAPED(expected, actual) \
|
||||
EXPECT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRCASEEQ, \
|
||||
expected, actual)
|
||||
#define EXPECT_STRCASEN_USE_ESCAPEDE(s1, s2)\
|
||||
EXPECT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRCASENE, \
|
||||
s1, s2)
|
||||
|
||||
#define ASSERT_STREQ_USE_ESCAPED(expected, actual) \
|
||||
ASSERT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTREQ, \
|
||||
expected, actual)
|
||||
#define ASSERT_STRNE_USE_ESCAPED(s1, s2) \
|
||||
ASSERT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRNE, s1, s2)
|
||||
#define ASSERT_STRCASEEQ_USE_ESCAPED(expected, actual) \
|
||||
ASSERT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRCASEEQ, \
|
||||
expected, actual)
|
||||
#define ASSERT_STRCASENE_USE_ESCAPED(s1, s2)\
|
||||
ASSERT_PRED_FORMAT2_USE_ESCAPED(::testing::internal::CmpHelperSTRCASENE, \
|
||||
s1, s2)
|
||||
|
||||
#else
|
||||
|
||||
#define EXPECT_STREQ_USE_ESCAPED EXPECT_STREQ
|
||||
#define EXPECT_STRNE_USE_ESCAPED EXPECT_STRNE
|
||||
#define EXPECT_STRCASEEQ_USE_ESCAPED EXPECT_STRCASEEQ
|
||||
#define EXPECT_STRCASENE_USE_ESCAPED EXPECT_STRCASENE
|
||||
#define ASSERT_STREQ_USE_ESCAPED ASSERT_STREQ
|
||||
#define ASSERT_STRNE_USE_ESCAPED ASSERT_STRNE
|
||||
#define ASSERT_STRCASEEQ_USE_ESCAPED ASSERT_STRCASEEQ
|
||||
#define ASSERT_STRCASENE_USE_ESCAPED ASSERT_STRCASENE
|
||||
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
|
||||
// Macros for comparing floating-point numbers.
|
||||
//
|
||||
// * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual):
|
||||
|
@ -1299,15 +1354,42 @@ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
|||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, ::testing::Message() << (message))
|
||||
|
||||
|
||||
namespace internal {
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// implementation borrowed from boost::is_same.
|
||||
template<typename T1>
|
||||
struct is_same_part_1 {
|
||||
template<typename T2> struct part_2 {
|
||||
enum { value = false };
|
||||
};
|
||||
template<> struct part_2<T1> {
|
||||
enum { value = true };
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct is_same {
|
||||
enum { value = is_same_part_1<T1>::part_2<T2>::value };
|
||||
};
|
||||
|
||||
// This template is declared, but intentionally undefined.
|
||||
template <bool b> struct StaticAssertTypeHelper;
|
||||
|
||||
template <> struct StaticAssertTypeHelper<true> {};
|
||||
|
||||
|
||||
#else // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct StaticAssertTypeEqHelper;
|
||||
|
||||
template <typename T>
|
||||
struct StaticAssertTypeEqHelper<T, T> {};
|
||||
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Compile-time assertion for type equality.
|
||||
|
@ -1340,12 +1422,23 @@ struct StaticAssertTypeEqHelper<T, T> {};
|
|||
// void Test2() { Foo<bool> foo; foo.Bar(); }
|
||||
//
|
||||
// to cause a compiler error.
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
bool StaticAssertTypeEq() {
|
||||
internal::StaticAssertTypeHelper<internal::is_same<T1, T2>::value>();
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
template <typename T1, typename T2>
|
||||
bool StaticAssertTypeEq() {
|
||||
internal::StaticAssertTypeEqHelper<T1, T2>();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// Defines a test.
|
||||
//
|
||||
// The first parameter is the name of the test case, and the second
|
||||
|
|
|
@ -100,7 +100,7 @@ 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),\
|
||||
GTEST_ASSERT_(pred_format(#v1, v1), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
||||
|
@ -148,7 +148,11 @@ 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),\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
|
||||
on_failure)
|
||||
|
||||
#define GTEST_PRED_FORMAT2_USE_ESCAPED_(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
|
||||
|
@ -164,15 +168,20 @@ AssertionResult AssertPred2Helper(const char* pred_text,
|
|||
// Binary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
|
||||
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED_FORMAT2_USE_ESCAPED(pred_format, v1, v2) \
|
||||
GTEST_PRED_FORMAT2_USE_ESCAPED_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
|
||||
#define EXPECT_PRED2(pred, v1, v2) \
|
||||
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_)
|
||||
#define ASSERT_PRED_FORMAT2_USE_ESCAPED(pred_format, v1, v2) \
|
||||
GTEST_PRED_FORMAT2_USE_ESCAPED_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED2(pred, v1, v2) \
|
||||
GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred,
|
||||
|
@ -203,7 +212,7 @@ 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),\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
||||
|
@ -265,7 +274,7 @@ 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),\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
||||
|
@ -334,7 +343,7 @@ 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),\
|
||||
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
|
||||
|
|
|
@ -92,11 +92,72 @@
|
|||
// ::operator<<;" in the definition of Message's operator<<. That fix
|
||||
// doesn't require a helper function, but unfortunately doesn't
|
||||
// compile with MSVC.
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1200)
|
||||
|
||||
// VC6 does not have std::ostream::operator<< which takes 64 bits integer.
|
||||
// For workaround, we should have own implementation.
|
||||
// See http://support.microsoft.com/?scid=kb;en-us;168440&x=4&y=7
|
||||
// note:The workaround above has buffer-overrun bug.
|
||||
// (in case of 0x8000000000000000("-9223372036854775808" ),
|
||||
// buf[20] is not enough! required 21 chars(with null trailor).
|
||||
// and also hex case (by setbase(16) or << ios::hex) seems not supported.
|
||||
inline std::ostream & operator << (std::ostream &ostream , __int64 val) { //NOLINT
|
||||
if (ostream.flags() & std::ios_base::dec) {
|
||||
char buf[21];
|
||||
_snprintf(buf, sizeof(buf), "%I64d", val);
|
||||
ostream << buf;
|
||||
} else if (ostream.flags() & std::ios_base::hex) {
|
||||
char buf[21];
|
||||
_snprintf(buf, sizeof(buf), "%I64x", val);
|
||||
ostream << buf;
|
||||
} else {
|
||||
ostream << "(oct output for 64 bit val not supported on VC6";
|
||||
}
|
||||
return ostream;
|
||||
}
|
||||
|
||||
inline std::ostream & operator << (std::ostream &ostream, unsigned __int64 val) { //NOLINT
|
||||
if (ostream.flags() & std::ios_base::dec) {
|
||||
char buf[21];
|
||||
_snprintf(buf, sizeof(buf) , "%I64u", val);
|
||||
ostream << buf;
|
||||
} else if (ostream.flags() & std::ios_base::hex) {
|
||||
char buf[21];
|
||||
_snprintf(buf, sizeof(buf), "%I64x", val);
|
||||
ostream << buf;
|
||||
} else {
|
||||
ostream << "(oct output for 64 bit val not supported on VC6";
|
||||
}
|
||||
return ostream;
|
||||
}
|
||||
#endif // (defined(_MSC_VER) && _MSC_VER <= 1200)
|
||||
|
||||
template <typename T>
|
||||
inline void GTestStreamToHelper(std::ostream* os, const T& val) {
|
||||
*os << val;
|
||||
}
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1200)
|
||||
// On MSVCV6, we should have special implemenation for std::string and
|
||||
// std::wstring.
|
||||
// Because implementation of operator <<(ostream &, string/wstring) does not
|
||||
// stream whole contents of string, in case of string includes null character.
|
||||
template <>
|
||||
inline void GTestStreamToHelper(std::ostream* os, const std::string &str) {
|
||||
for (size_t i = 0 ; i < str.size() ; i++) {
|
||||
os->put(str[i]);
|
||||
}
|
||||
}
|
||||
template <>
|
||||
inline void GTestStreamToHelper(std::ostream* os, const std::wstring &str) {
|
||||
for (size_t i = 0 ; i < str.size() ; i++) {
|
||||
os->put(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // (defined(_MSC_VER) && _MSC_VER <= 1200)
|
||||
|
||||
namespace testing {
|
||||
|
||||
// Forward declaration of classes.
|
||||
|
@ -224,8 +285,10 @@ inline String FormatValueForFailureMessage(internal::false_type dummy,
|
|||
|
||||
template <typename T>
|
||||
inline String FormatForFailureMessage(const T& value) {
|
||||
typename internal::is_pointer<T>::type true_or_false;
|
||||
|
||||
return FormatValueForFailureMessage(
|
||||
typename internal::is_pointer<T>::type(), value);
|
||||
true_or_false, value);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -343,25 +406,29 @@ class FloatingPoint {
|
|||
|
||||
// Constants.
|
||||
|
||||
// MSVC6 does not support initialization of static const member
|
||||
// in class difinition. so initializer are go out.
|
||||
// # of bits in a number.
|
||||
static const size_t kBitCount = 8*sizeof(RawType);
|
||||
static const size_t kBitCount; // = 8*sizeof(RawType);
|
||||
|
||||
// # of fraction bits in a number.
|
||||
static const size_t kFractionBitCount =
|
||||
std::numeric_limits<RawType>::digits - 1;
|
||||
// //VC6 does not support initialize static const here!
|
||||
static const size_t kFractionBitCount; // =
|
||||
// std::numeric_limits<RawType>::digits - 1;
|
||||
|
||||
// # of exponent bits in a number.
|
||||
static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
|
||||
static const size_t kExponentBitCount; // =
|
||||
// kBitCount - 1 - kFractionBitCount;
|
||||
|
||||
// The mask for the sign bit.
|
||||
static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
|
||||
static const Bits kSignBitMask; // = static_cast<Bits>(1) << (kBitCount - 1);
|
||||
|
||||
// The mask for the fraction bits.
|
||||
static const Bits kFractionBitMask =
|
||||
~static_cast<Bits>(0) >> (kExponentBitCount + 1);
|
||||
static const Bits kFractionBitMask; // =
|
||||
// ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
|
||||
|
||||
// The mask for the exponent bits.
|
||||
static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
|
||||
static const Bits kExponentBitMask; // = ~(kSignBitMask | kFractionBitMask);
|
||||
|
||||
// How many ULP's (Units in the Last Place) we want to tolerate when
|
||||
// comparing two numbers. The larger the value, the more error we
|
||||
|
@ -375,7 +442,7 @@ class FloatingPoint {
|
|||
//
|
||||
// See the following article for more details on ULP:
|
||||
// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm.
|
||||
static const size_t kMaxUlps = 4;
|
||||
static const size_t kMaxUlps; // = 4;
|
||||
|
||||
// Constructs a FloatingPoint from a raw floating-point number.
|
||||
//
|
||||
|
@ -481,6 +548,66 @@ class FloatingPoint {
|
|||
FloatingPointUnion u_;
|
||||
};
|
||||
|
||||
template <typename RawType> const size_t FloatingPoint<RawType>::kBitCount
|
||||
= getBitCount<RawType>();
|
||||
template <typename RawType>
|
||||
const size_t FloatingPoint<RawType>::kFractionBitCount
|
||||
= getFractionBitCount<RawType>();
|
||||
template <typename RawType>
|
||||
const size_t FloatingPoint<RawType>::kExponentBitCount
|
||||
= getExponentBitCount<RawType>();
|
||||
|
||||
template <typename RawType> const typename FloatingPoint<RawType>::Bits
|
||||
FloatingPoint<RawType>::kSignBitMask = getSignBitMask<RawType>();
|
||||
|
||||
template <typename RawType> const typename FloatingPoint<RawType>::Bits
|
||||
FloatingPoint<RawType>::kFractionBitMask = getFractionBitMask<RawType>();
|
||||
|
||||
template <typename RawType> const typename FloatingPoint<RawType>::Bits
|
||||
FloatingPoint<RawType>::kExponentBitMask = getExponentBitMask<RawType>();
|
||||
|
||||
template <typename RawType> const size_t FloatingPoint<RawType>::kMaxUlps = 4;
|
||||
|
||||
// prevent "static initialization order fiasco"
|
||||
template <typename RawType> size_t getBitCount() {
|
||||
static size_t bitCount = 8 * sizeof(RawType);
|
||||
return bitCount;
|
||||
}
|
||||
template <typename RawType> size_t getFractionBitCount() {
|
||||
static size_t fractionBitCount = std::numeric_limits<RawType>::digits - 1;
|
||||
return fractionBitCount;
|
||||
}
|
||||
template <typename RawType> size_t getExponentBitCount() {
|
||||
static size_t exponentBitCount
|
||||
= getBitCount<RawType>() - 1 - getFractionBitCount<RawType>();
|
||||
return exponentBitCount;
|
||||
}
|
||||
|
||||
template <typename RawType> typename
|
||||
FloatingPoint<RawType>::Bits getSignBitMask() {
|
||||
typedef typename FloatingPoint<RawType>::Bits MyBits;
|
||||
static MyBits signBits
|
||||
= static_cast<MyBits>(1) << (getBitCount<RawType>() - 1);
|
||||
return signBits;
|
||||
}
|
||||
|
||||
template <typename RawType> typename
|
||||
FloatingPoint<RawType>::Bits getFractionBitMask() {
|
||||
typedef typename FloatingPoint<RawType>::Bits MyBits;
|
||||
static MyBits fractionBits
|
||||
= ~static_cast<MyBits>(0) >> (getExponentBitCount<RawType>() + 1);
|
||||
return fractionBits;
|
||||
}
|
||||
|
||||
template <typename RawType> typename
|
||||
FloatingPoint<RawType>::Bits getExponentBitMask() {
|
||||
typedef typename FloatingPoint<RawType>::Bits MyBits;
|
||||
static MyBits exponentBits
|
||||
= ~(getSignBitMask<RawType>() | getFractionBitMask<RawType>());
|
||||
return exponentBits;
|
||||
}
|
||||
|
||||
|
||||
// Typedefs the instances of the FloatingPoint template class that we
|
||||
// care to use.
|
||||
typedef FloatingPoint<float> Float;
|
||||
|
@ -509,8 +636,11 @@ bool TypeIdHelper<T>::dummy_ = false;
|
|||
// GetTypeId<T>() returns the ID of type T. Different values will be
|
||||
// returned for different types. Calling the function twice with the
|
||||
// same type argument is guaranteed to return the same ID.
|
||||
|
||||
// Parameter "T *unused" is unused but required for workaround for MSVC6.
|
||||
// see http://support.microsoft.com/?scid=kb;en-us;240871&x=8&y=9
|
||||
template <typename T>
|
||||
TypeId GetTypeId() {
|
||||
TypeId GetTypeId(T *unused = NULL) {
|
||||
// The compiler is required to allocate a different
|
||||
// TypeIdHelper<T>::dummy_ variable for each T used to instantiate
|
||||
// the template. Therefore, the address of dummy_ is guaranteed to
|
||||
|
@ -763,9 +893,23 @@ bool AlwaysTrue();
|
|||
::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, message) \
|
||||
= ::testing::Message()
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <=1200
|
||||
// MSVC6 does not allow to return from void function
|
||||
// with calling void function.
|
||||
#define GTEST_FATAL_FAILURE_(message) \
|
||||
if (int count=1) \
|
||||
while (true) \
|
||||
if (0 == count--) \
|
||||
return; \
|
||||
else GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE) //NOLINT
|
||||
|
||||
|
||||
#else // defined(_MSC_VER) && _MSC_VER <=1200
|
||||
#define GTEST_FATAL_FAILURE_(message) \
|
||||
return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE)
|
||||
|
||||
#endif // defined(_MSC_VER) && _MSC_VER <=1200
|
||||
|
||||
#define GTEST_NONFATAL_FAILURE_(message) \
|
||||
GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE)
|
||||
|
||||
|
@ -778,6 +922,42 @@ bool AlwaysTrue();
|
|||
#define GTEST_HIDE_UNREACHABLE_CODE_(statement) \
|
||||
if (::testing::internal::AlwaysTrue()) { statement; }
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// MSVC6 seems can't handle goto and GTEST_CONCAT_TOKEN well..
|
||||
// So below is non-goto version.
|
||||
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
|
||||
if (const char* gtest_msg = "")\
|
||||
if (bool not_caught_expected = true) \
|
||||
if (int count = 2) \
|
||||
while ((count--) && (not_caught_expected) ) \
|
||||
if ((count == 1) && not_caught_expected) { \
|
||||
bool caught_unexpected_exception = false; \
|
||||
try { \
|
||||
statement; \
|
||||
} \
|
||||
catch(expected_exception const&) { \
|
||||
not_caught_expected = false; \
|
||||
} \
|
||||
catch(...) { \
|
||||
gtest_msg = "Expected: " #statement \
|
||||
" throws an exception of type " \
|
||||
#expected_exception \
|
||||
".\n Actual: it throws a different " \
|
||||
"type."; \
|
||||
caught_unexpected_exception = true; \
|
||||
} \
|
||||
if (not_caught_expected && (!caught_unexpected_exception)) { \
|
||||
gtest_msg = "Expected: " #statement \
|
||||
" throws an exception of type " \
|
||||
#expected_exception \
|
||||
".\n Actual: it throws nothing."; \
|
||||
} \
|
||||
} else \
|
||||
if (not_caught_expected) \
|
||||
fail(gtest_msg)
|
||||
|
||||
#else // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
|
@ -785,10 +965,10 @@ bool AlwaysTrue();
|
|||
try { \
|
||||
GTEST_HIDE_UNREACHABLE_CODE_(statement); \
|
||||
} \
|
||||
catch (expected_exception const&) { \
|
||||
catch(expected_exception const&) { \
|
||||
gtest_caught_expected = true; \
|
||||
} \
|
||||
catch (...) { \
|
||||
catch(...) { \
|
||||
gtest_msg = "Expected: " #statement " throws an exception of type " \
|
||||
#expected_exception ".\n Actual: it throws a different " \
|
||||
"type."; \
|
||||
|
@ -803,13 +983,39 @@ bool AlwaysTrue();
|
|||
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#endif // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||
if (const char* gtest_msg="")\
|
||||
if (bool not_caught = true) \
|
||||
if (int count = 2) \
|
||||
while ( count-- ) \
|
||||
if ((count == 1) && not_caught) { \
|
||||
try { \
|
||||
statement; \
|
||||
} \
|
||||
catch(...) { \
|
||||
gtest_msg = "Expected: " #statement \
|
||||
" doesn't throw an exception.\n" \
|
||||
" Actual: it throws."; \
|
||||
not_caught = false; \
|
||||
} \
|
||||
} else \
|
||||
if (!not_caught) \
|
||||
fail(gtest_msg)
|
||||
|
||||
#else // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
|
||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
try { \
|
||||
GTEST_HIDE_UNREACHABLE_CODE_(statement); \
|
||||
} \
|
||||
catch (...) { \
|
||||
catch(...) { \
|
||||
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
|
||||
" Actual: it throws."; \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||
|
@ -818,6 +1024,31 @@ bool AlwaysTrue();
|
|||
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#endif // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||
if (const char* gtest_msg="")\
|
||||
if (bool not_caught = true) \
|
||||
if (int count = 2) \
|
||||
while ( count-- ) \
|
||||
if ((count == 1) && not_caught) { \
|
||||
try { \
|
||||
statement; \
|
||||
} \
|
||||
catch(...) { \
|
||||
not_caught = false; \
|
||||
} \
|
||||
if (not_caught) { \
|
||||
gtest_msg = "Expected: " #statement " throws an exception.\n" \
|
||||
" Actual: it doesn't."; \
|
||||
} \
|
||||
} else \
|
||||
if (not_caught) \
|
||||
fail(gtest_msg)
|
||||
|
||||
#else // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
|
@ -825,7 +1056,7 @@ bool AlwaysTrue();
|
|||
try { \
|
||||
GTEST_HIDE_UNREACHABLE_CODE_(statement); \
|
||||
} \
|
||||
catch (...) { \
|
||||
catch(...) { \
|
||||
gtest_caught_any = true; \
|
||||
} \
|
||||
if (!gtest_caught_any) { \
|
||||
|
@ -836,7 +1067,7 @@ bool AlwaysTrue();
|
|||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#endif // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
#define GTEST_TEST_BOOLEAN_(boolexpr, booltext, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
|
@ -845,6 +1076,30 @@ bool AlwaysTrue();
|
|||
else \
|
||||
fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expected)
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
if (const char* gtest_msg="")\
|
||||
if (bool has_no_new_fatal_failure = true) \
|
||||
if (int count = 2) \
|
||||
while ( count-- ) \
|
||||
if ((count == 1) && has_no_new_fatal_failure) { \
|
||||
::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."; \
|
||||
has_no_new_fatal_failure = false; \
|
||||
} \
|
||||
} else \
|
||||
if (!has_no_new_fatal_failure) \
|
||||
fail(gtest_msg)
|
||||
|
||||
#else // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const char* gtest_msg = "") { \
|
||||
|
@ -860,6 +1115,8 @@ bool AlwaysTrue();
|
|||
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
|
||||
fail(gtest_msg)
|
||||
|
||||
#endif // _defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
// 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
|
||||
|
|
|
@ -684,7 +684,14 @@ typedef GTestMutexLock MutexLock;
|
|||
template <typename T>
|
||||
class ThreadLocal {
|
||||
public:
|
||||
ThreadLocal() : value_() {}
|
||||
ThreadLocal() : value_() {
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// in MSVC6, initialize value_ again, because MSVC6 can't
|
||||
// call default initializer correctly for member if in initialisor list
|
||||
// like ThreadLocal() : value_()
|
||||
value_ = T();
|
||||
#endif
|
||||
}
|
||||
explicit ThreadLocal(const T& value) : value_(value) {}
|
||||
T* pointer() { return &value_; }
|
||||
const T* pointer() const { return &value_; }
|
||||
|
@ -718,22 +725,52 @@ size_t GetThreadCount();
|
|||
#define GTEST_NEEDS_IS_POINTER_ 1
|
||||
|
||||
#endif // defined(__SYMBIAN32__) || defined(__IBMCPP__)
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
// in MSVC6, template specializer for decide T and T *does not work,
|
||||
// so here are workarounds.
|
||||
#define GTEST_NEEDS_IS_POINTER_ 1
|
||||
|
||||
template <bool bool_value>
|
||||
struct bool_constant {
|
||||
typedef bool_constant<bool_value> type;
|
||||
static const bool value = bool_value;
|
||||
};
|
||||
template <bool bool_value> const bool bool_constant<bool_value>::value;
|
||||
template <bool bool_value> struct bool_type {};
|
||||
template <typename T> struct is_pointer {
|
||||
typedef char yestype;
|
||||
typedef struct {
|
||||
char dummy[2];
|
||||
}notype;
|
||||
|
||||
typedef bool_constant<false> false_type;
|
||||
typedef bool_constant<true> true_type;
|
||||
inline static yestype tester(const volatile void *);
|
||||
inline static notype tester(...);
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer : public false_type {};
|
||||
inline static T& make_t();
|
||||
enum {
|
||||
value = sizeof(tester(make_t())) == sizeof(yestype)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer<T*> : public true_type {};
|
||||
typedef bool_type<value> type;
|
||||
};
|
||||
template <> struct is_pointer<void> {
|
||||
enum {value =0};
|
||||
};
|
||||
typedef bool_type<false> false_type;
|
||||
typedef bool_type<true> true_type;
|
||||
#else
|
||||
|
||||
template <bool bool_value>
|
||||
struct bool_constant {
|
||||
typedef bool_constant<bool_value> type;
|
||||
static const bool value = bool_value;
|
||||
};
|
||||
template <bool bool_value> const bool bool_constant<bool_value>::value;
|
||||
|
||||
typedef bool_constant<false> false_type;
|
||||
typedef bool_constant<true> true_type;
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer : public false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer<T*> : public true_type {};
|
||||
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#define GTEST_PATH_SEP_ "\\"
|
||||
|
|
|
@ -219,7 +219,7 @@ class String {
|
|||
|
||||
// D'tor. String is intended to be a final class, so the d'tor
|
||||
// doesn't need to be virtual.
|
||||
~String() { delete[] c_str_; }
|
||||
~String() { delete[] const_cast<char *>(c_str_); }
|
||||
|
||||
// Allows a String to be implicitly converted to an ::std::string or
|
||||
// ::string, and vice versa. Converting a String containing a NULL
|
||||
|
|
264
branches/unsupported-vc6-port/msvc6/gtest.dsp
Normal file
264
branches/unsupported-vc6-port/msvc6/gtest.dsp
Normal file
|
@ -0,0 +1,264 @@
|
|||
# Microsoft Developer Studio Project File - Name="gtest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** 編集しないでください **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=gtest - Win32 Debug
|
||||
!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
|
||||
!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE の実行時に構成を指定できます
|
||||
!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest.mak" CFG="gtest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE 選択可能なビルド モード:
|
||||
!MESSAGE
|
||||
!MESSAGE "gtest - Win32 Release" ("Win32 (x86) Static Library" 用)
|
||||
!MESSAGE "gtest - Win32 Debug" ("Win32 (x86) Static Library" 用)
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../include" /I "../" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "NDEBUG"
|
||||
# ADD RSC /l 0x411 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "_DEBUG"
|
||||
# ADD RSC /l 0x411 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\gtestd.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "gtest - Win32 Release"
|
||||
# Name "gtest - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-death-test.cc"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-filepath.cc"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-port.cc"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-test-part.cc"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-typed-test.cc"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\gtest.cc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\internal\gtest-death-test-internal.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\gtest-death-test.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\internal\gtest-filepath.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\gtest-internal-inl.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\internal\gtest-internal.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\gtest-message.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\internal\gtest-port.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\gtest-spi.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\include\gtest\internal\gtest-string.h"
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\gtest\gtest.h
|
||||
|
||||
!IF "$(CFG)" == "gtest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\gtest\gtest_pred_impl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\gtest\gtest_prod.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
59
branches/unsupported-vc6-port/msvc6/gtest.dsw
Normal file
59
branches/unsupported-vc6-port/msvc6/gtest.dsw
Normal file
|
@ -0,0 +1,59 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# 警告: このワークスペース ファイル を編集または削除しないでください!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "gtest"=.\gtest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "gtest_main"=.\gtest_main.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name gtest
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "gtest_unittest"=.\gtest_unittest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name gtest_main
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
96
branches/unsupported-vc6-port/msvc6/gtest_main.dsp
Normal file
96
branches/unsupported-vc6-port/msvc6/gtest_main.dsp
Normal file
|
@ -0,0 +1,96 @@
|
|||
# Microsoft Developer Studio Project File - Name="gtest_main" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** 編集しないでください **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=gtest_main - Win32 Debug
|
||||
!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
|
||||
!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest_main.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE の実行時に構成を指定できます
|
||||
!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest_main.mak" CFG="gtest_main - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE 選択可能なビルド モード:
|
||||
!MESSAGE
|
||||
!MESSAGE "gtest_main - Win32 Release" ("Win32 (x86) Static Library" 用)
|
||||
!MESSAGE "gtest_main - Win32 Debug" ("Win32 (x86) Static Library" 用)
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "gtest_main - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../include" /I "../" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "NDEBUG"
|
||||
# ADD RSC /l 0x411 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest_main - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "_DEBUG"
|
||||
# ADD RSC /l 0x411 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "gtest_main - Win32 Release"
|
||||
# Name "gtest_main - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\gtest_main.cc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
100
branches/unsupported-vc6-port/msvc6/gtest_unittest.dsp
Normal file
100
branches/unsupported-vc6-port/msvc6/gtest_unittest.dsp
Normal file
|
@ -0,0 +1,100 @@
|
|||
# Microsoft Developer Studio Project File - Name="gtest_unittest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** 編集しないでください **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=gtest_unittest - Win32 Debug
|
||||
!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
|
||||
!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest_unittest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE の実行時に構成を指定できます
|
||||
!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gtest_unittest.mak" CFG="gtest_unittest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE 選択可能なビルド モード:
|
||||
!MESSAGE
|
||||
!MESSAGE "gtest_unittest - Win32 Release" ("Win32 (x86) Console Application" 用)
|
||||
!MESSAGE "gtest_unittest - Win32 Debug" ("Win32 (x86) Console Application" 用)
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "gtest_unittest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "NDEBUG"
|
||||
# ADD RSC /l 0x411 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "gtest_unittest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../gtest" /I "../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /TP /c
|
||||
# ADD BASE RSC /l 0x411 /d "_DEBUG"
|
||||
# ADD RSC /l 0x411 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "gtest_unittest - Win32 Release"
|
||||
# Name "gtest_unittest - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\test\gtest_unittest.cc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -187,8 +187,9 @@ bool FilePath::DirectoryExists() const {
|
|||
#if GTEST_OS_WINDOWS
|
||||
// Don't strip off trailing separator if path is a root directory on
|
||||
// Windows (like "C:\\").
|
||||
const FilePath& path(IsRootDirectory() ? *this :
|
||||
RemoveTrailingPathSeparator());
|
||||
const FilePath& path = IsRootDirectory() ? *this :
|
||||
FilePath(RemoveTrailingPathSeparator());
|
||||
|
||||
#else
|
||||
const FilePath& path(*this);
|
||||
#endif
|
||||
|
|
|
@ -434,7 +434,10 @@ class List {
|
|||
int size_; // The number of elements in the list.
|
||||
|
||||
// We disallow copying List.
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||
#else
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(List);
|
||||
#endif
|
||||
};
|
||||
|
||||
// The virtual destructor of List.
|
||||
|
@ -443,12 +446,15 @@ List<E>::~List() {
|
|||
Clear();
|
||||
}
|
||||
|
||||
// A function for deleting an object. Handy for being used as a
|
||||
// functor.
|
||||
// A functor for deleting an object.
|
||||
// Function does not work on MSVC6.
|
||||
template <typename T>
|
||||
static void Delete(T * x) {
|
||||
delete x;
|
||||
}
|
||||
struct Delete {
|
||||
void operator()(T *x) {
|
||||
delete x;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// A copyable object representing a user specified test property which can be
|
||||
// output as a key/value string pair.
|
||||
|
|
|
@ -735,7 +735,7 @@ String UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
|
|||
}
|
||||
|
||||
static TimeInMillis GetTimeInMillis() {
|
||||
#if defined(_WIN32_WCE) || defined(__BORLANDC__)
|
||||
#if defined(_WIN32_WCE) || defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER <= 1200)
|
||||
// Difference between 1970-01-01 and 1601-01-01 in miliseconds.
|
||||
// http://analogous.blogspot.com/2005/04/epoch.html
|
||||
const TimeInMillis kJavaEpochToWinFileTimeDelta =
|
||||
|
@ -1681,7 +1681,11 @@ bool String::EndsWithCaseInsensitive(const char* suffix) const {
|
|||
void String::Set(const char * c_str, size_t length) {
|
||||
// Makes sure this works when c_str == c_str_
|
||||
const char* const temp = CloneString(c_str, length);
|
||||
delete[] c_str_;
|
||||
|
||||
// const_cast is used for workaround for MSVC6.
|
||||
// See [delete-const-pointer] Deleting const X * does not work in
|
||||
// http://docs.huihoo.com/boost/1-33-1/more/microsoft_vcpp.html
|
||||
delete[] const_cast<char *>(c_str_);
|
||||
c_str_ = temp;
|
||||
}
|
||||
|
||||
|
@ -1689,7 +1693,10 @@ void String::Set(const char * c_str, size_t length) {
|
|||
const String& String::operator=(const char* c_str) {
|
||||
// Makes sure this works when c_str == c_str_
|
||||
if (c_str != c_str_) {
|
||||
delete[] c_str_;
|
||||
// const_cast is used for workaround for MSVC6.
|
||||
// See [delete-const-pointer] Deleting const X * does not work in
|
||||
// http://docs.huihoo.com/boost/1-33-1/more/microsoft_vcpp.html
|
||||
delete[] const_cast<char *>(c_str_);
|
||||
c_str_ = CloneCString(c_str);
|
||||
}
|
||||
return *this;
|
||||
|
@ -2352,7 +2359,7 @@ TestCase::TestCase(const char* name, const char* comment,
|
|||
// Destructor of TestCase.
|
||||
TestCase::~TestCase() {
|
||||
// Deletes every Test in the collection.
|
||||
test_info_list_->ForEach(internal::Delete<TestInfo>);
|
||||
test_info_list_->ForEach(internal::Delete<TestInfo>());
|
||||
|
||||
// Then deletes the Test collection.
|
||||
delete test_info_list_;
|
||||
|
@ -3502,10 +3509,10 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
|
|||
|
||||
UnitTestImpl::~UnitTestImpl() {
|
||||
// Deletes every TestCase.
|
||||
test_cases_.ForEach(internal::Delete<TestCase>);
|
||||
test_cases_.ForEach(internal::Delete<TestCase>());
|
||||
|
||||
// Deletes every Environment.
|
||||
environments_.ForEach(internal::Delete<Environment>);
|
||||
environments_.ForEach(internal::Delete<Environment>());
|
||||
|
||||
// Deletes the current test result printer.
|
||||
delete result_printer_;
|
||||
|
|
|
@ -125,6 +125,35 @@ TEST(MessageTest, StreamsInt) {
|
|||
EXPECT_STREQ("123", ToCString(Message() << 123));
|
||||
}
|
||||
|
||||
// Tests streaming int64.
|
||||
TEST(MessageTest, StreamInt64) {
|
||||
testing::Message msg;
|
||||
msg << __int64(100);
|
||||
EXPECT_STREQ("100", msg.GetString().c_str());
|
||||
}
|
||||
|
||||
// Tests streaming int64 as Hex.
|
||||
TEST(MessageTest , StreamInt64AsHex) {
|
||||
testing::Message msg;
|
||||
msg << "0x" << std::setbase(16) << __int64(100);
|
||||
EXPECT_STREQ("0x64", msg.GetString().c_str());
|
||||
}
|
||||
|
||||
// Tests streaming uint64.
|
||||
TEST(MessageTest , StreamUInt64) {
|
||||
testing::Message msg;
|
||||
msg << unsigned __int64(100);
|
||||
EXPECT_STREQ("100", msg.GetString().c_str());
|
||||
}
|
||||
|
||||
// Tests streaming uint64 as Hex
|
||||
TEST(MessageTest , StreamUInt64AsHex) {
|
||||
testing::Message msg;
|
||||
msg << "0x" << std::setbase(16) << unsigned __int64(100) << ",L\'x\'=0x"
|
||||
<< L'x';
|
||||
EXPECT_STREQ("0x64,L\'x\'=0x78", msg.GetString().c_str());
|
||||
}
|
||||
|
||||
// Tests that basic IO manipulators (endl, ends, and flush) can be
|
||||
// streamed to Message.
|
||||
TEST(MessageTest, StreamsBasicIoManip) {
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER == 1200)
|
||||
#define GTEST_MSVC6 1
|
||||
#else
|
||||
#define GETST_MSVC6 0
|
||||
#endif
|
||||
|
||||
// Verifies that the command line flag variables can be accessed
|
||||
// in code once <gtest/gtest.h> has been #included.
|
||||
// Do not move it after other #includes.
|
||||
|
@ -160,25 +166,36 @@ using testing::internal::UnitTestImpl;
|
|||
using testing::internal::WideStringToUtf8;
|
||||
|
||||
// This line tests that we can define tests in an unnamed namespace.
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// Tests GetTypeId.
|
||||
|
||||
// Tests GetTypeId.
|
||||
TEST(GetTypeIdTest, ReturnsSameValueForSameType) {
|
||||
EXPECT_EQ(GetTypeId<int>(), GetTypeId<int>());
|
||||
EXPECT_EQ(GetTypeId<Test>(), GetTypeId<Test>());
|
||||
// "testing::internal" is explicitly coded for support MSVC6
|
||||
// which has broken "using" for template function,
|
||||
EXPECT_EQ(testing::internal::GetTypeId<int>(),
|
||||
testing::internal::GetTypeId<int>());
|
||||
EXPECT_EQ(testing::internal::GetTypeId<Test>(),
|
||||
testing::internal::GetTypeId<Test>());
|
||||
}
|
||||
|
||||
class SubClassOfTest : public Test {};
|
||||
class AnotherSubClassOfTest : public Test {};
|
||||
|
||||
TEST(GetTypeIdTest, ReturnsDifferentValuesForDifferentTypes) {
|
||||
EXPECT_NE(GetTypeId<int>(), GetTypeId<const int>());
|
||||
EXPECT_NE(GetTypeId<int>(), GetTypeId<char>());
|
||||
EXPECT_NE(GetTypeId<int>(), GetTestTypeId());
|
||||
EXPECT_NE(GetTypeId<SubClassOfTest>(), GetTestTypeId());
|
||||
EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTestTypeId());
|
||||
EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTypeId<SubClassOfTest>());
|
||||
EXPECT_NE(testing::internal::GetTypeId<int>(),
|
||||
testing::internal::GetTypeId<const int>());
|
||||
EXPECT_NE(testing::internal::GetTypeId<int>(),
|
||||
testing::internal::GetTypeId<char>());
|
||||
EXPECT_NE(testing::internal::GetTypeId<int>(),
|
||||
testing::internal::GetTestTypeId());
|
||||
EXPECT_NE(testing::internal::GetTypeId<SubClassOfTest>(), GetTestTypeId());
|
||||
EXPECT_NE(testing::internal::GetTypeId<AnotherSubClassOfTest>(),
|
||||
GetTestTypeId());
|
||||
EXPECT_NE(testing::internal::GetTypeId<AnotherSubClassOfTest>(),
|
||||
testing::internal::GetTypeId<SubClassOfTest>());
|
||||
}
|
||||
|
||||
// Verifies that GetTestTypeId() returns the same value, no matter it
|
||||
|
@ -272,7 +289,13 @@ TEST(CodePointToUtf8Test, CanEncodeAscii) {
|
|||
TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
|
||||
char buffer[32];
|
||||
// 000 1101 0011 => 110-00011 10-010011
|
||||
#if GTEST_MSVC6
|
||||
// I don't know the reason but in MSVC6, L'\xD3' is compiled as 0xFF93,
|
||||
// which is not expected.
|
||||
EXPECT_STREQ("\xC3\x93", CodePointToUtf8(0xD3, buffer));
|
||||
#else
|
||||
EXPECT_STREQ("\xC3\x93", CodePointToUtf8(L'\xD3', buffer));
|
||||
#endif
|
||||
|
||||
// 101 0111 0110 => 110-10101 10-110110
|
||||
EXPECT_STREQ("\xD5\xB6", CodePointToUtf8(L'\x576', buffer));
|
||||
|
@ -337,8 +360,18 @@ TEST(WideStringToUtf8Test, CanEncodeAscii) {
|
|||
// as 110xxxxx 10xxxxxx.
|
||||
TEST(WideStringToUtf8Test, CanEncode8To11Bits) {
|
||||
// 000 1101 0011 => 110-00011 10-010011
|
||||
#if GTEST_MSVC6
|
||||
// I don't know the reason but in VC6, L'\xD3' is compiled as 0xFF93,
|
||||
// which is not expected.
|
||||
wchar_t d3[2];
|
||||
d3[0] = static_cast<wchar_t>(0xD3);
|
||||
d3[1] = L'\0';
|
||||
EXPECT_STREQ("\xC3\x93", WideStringToUtf8(d3, 1).c_str());
|
||||
EXPECT_STREQ("\xC3\x93", WideStringToUtf8(d3, -1).c_str());
|
||||
#else
|
||||
EXPECT_STREQ("\xC3\x93", WideStringToUtf8(L"\xD3", 1).c_str());
|
||||
EXPECT_STREQ("\xC3\x93", WideStringToUtf8(L"\xD3", -1).c_str());
|
||||
#endif
|
||||
|
||||
// 101 0111 0110 => 110-10101 10-110110
|
||||
EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(L"\x576", 1).c_str());
|
||||
|
@ -635,9 +668,9 @@ TEST(StringTest, ShowCString) {
|
|||
TEST(StringTest, ShowCStringQuoted) {
|
||||
EXPECT_STREQ("(null)",
|
||||
String::ShowCStringQuoted(NULL).c_str());
|
||||
EXPECT_STREQ("\"\"",
|
||||
EXPECT_STREQ_USE_ESCAPED("\"\"",
|
||||
String::ShowCStringQuoted("").c_str());
|
||||
EXPECT_STREQ("\"foo\"",
|
||||
EXPECT_STREQ_USE_ESCAPED("\"foo\"",
|
||||
String::ShowCStringQuoted("foo").c_str());
|
||||
}
|
||||
|
||||
|
@ -767,9 +800,9 @@ TEST(StringTest, ShowWideCString) {
|
|||
TEST(StringTest, ShowWideCStringQuoted) {
|
||||
EXPECT_STREQ("(null)",
|
||||
String::ShowWideCStringQuoted(NULL).c_str());
|
||||
EXPECT_STREQ("L\"\"",
|
||||
EXPECT_STREQ_USE_ESCAPED("L\"\"",
|
||||
String::ShowWideCStringQuoted(L"").c_str());
|
||||
EXPECT_STREQ("L\"foo\"",
|
||||
EXPECT_STREQ_USE_ESCAPED("L\"foo\"",
|
||||
String::ShowWideCStringQuoted(L"foo").c_str());
|
||||
}
|
||||
|
||||
|
@ -817,7 +850,7 @@ TEST(TestPropertyTest, ReplaceStringValue) {
|
|||
|
||||
// AddFatalFailure() and AddNonfatalFailure() must be stand-alone
|
||||
// functions (i.e. their definitions cannot be inlined at the call
|
||||
// sites), or C++Builder won't compile the code.
|
||||
// sites), or C++Builder/MSVC6 won't compile the code.
|
||||
static void AddFatalFailure() {
|
||||
FAIL() << "Expected fatal failure.";
|
||||
}
|
||||
|
@ -828,6 +861,11 @@ static void AddNonfatalFailure() {
|
|||
|
||||
class ScopedFakeTestPartResultReporterTest : public Test {
|
||||
public: // Must be public and not protected due to a bug in g++ 3.4.2.
|
||||
#if GTEST_MSVC6
|
||||
// MSVC6 can't access protected member from function inner class
|
||||
public:
|
||||
#endif // GTEST_MSVC6
|
||||
|
||||
enum FailureMode {
|
||||
FATAL_FAILURE,
|
||||
NONFATAL_FAILURE
|
||||
|
@ -981,7 +1019,7 @@ TEST_F(ExpectFatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {
|
|||
GTEST_USE_UNPROTECTED_COMMA_;
|
||||
AddFatalFailure();
|
||||
}, "");
|
||||
#endif
|
||||
#endif // __BORLANDC__
|
||||
|
||||
EXPECT_FATAL_FAILURE_ON_ALL_THREADS({
|
||||
GTEST_USE_UNPROTECTED_COMMA_;
|
||||
|
@ -1745,6 +1783,39 @@ TEST(Pred1Test, WithFormat) {
|
|||
|
||||
// Tests that unary predicate assertions evaluates their arguments
|
||||
// exactly once.
|
||||
|
||||
#if GTEST_MSVC6
|
||||
// On MSVC6, use fixture with static member.
|
||||
// because we can't access static int n from EXPECT_FATAL_FAILURE macro
|
||||
// (MSVC6 does not allow to access function static variable from nested class's
|
||||
// static function.)
|
||||
// Furthermore, from EXPECT_FATAL_FAILURE() macro, static member of outer
|
||||
// class required to be accessed with class name explicitly and required to be
|
||||
// public!
|
||||
class Pred1TestMSVC6 : public ::testing::Test {
|
||||
public:
|
||||
static int n;
|
||||
};
|
||||
int Pred1TestMSVC6::n = 0;
|
||||
|
||||
TEST_F(Pred1TestMSVC6, SingleEvaluationOnFailure) {
|
||||
// A success case.
|
||||
n = 0;
|
||||
EXPECT_PRED1(IsEven, n++);
|
||||
EXPECT_EQ(1, n) << "The argument is not evaluated exactly once.";
|
||||
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(false, true),
|
||||
"Value of: true");
|
||||
// A failure case.
|
||||
EXPECT_FATAL_FAILURE({ // NOLINT
|
||||
ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), Pred1TestMSVC6::n++)
|
||||
<< "This failure is expected.";
|
||||
}, "This failure is expected.");
|
||||
EXPECT_EQ(2, n) << "The argument is not evaluated exactly once.";
|
||||
}
|
||||
|
||||
#else // GTEST_MSVC6
|
||||
|
||||
TEST(Pred1Test, SingleEvaluationOnFailure) {
|
||||
// A success case.
|
||||
static int n = 0;
|
||||
|
@ -1759,6 +1830,8 @@ TEST(Pred1Test, SingleEvaluationOnFailure) {
|
|||
EXPECT_EQ(2, n) << "The argument is not evaluated exactly once.";
|
||||
}
|
||||
|
||||
#endif // GTEST_MSVC6
|
||||
|
||||
|
||||
// Tests predicate assertions whose arity is >= 2.
|
||||
|
||||
|
@ -1878,6 +1951,14 @@ TEST(PredicateAssertionTest, AcceptsOverloadedFunction) {
|
|||
// Tests that template functions can be used in *_PRED* as long as
|
||||
// their types are explicitly specified.
|
||||
TEST(PredicateAssertionTest, AcceptsTemplateFunction) {
|
||||
// MSVC6 cause link error if you specify template function for
|
||||
// ASSERT_PRED2/EXPECT_PRED directly.
|
||||
// So need to force template instantiation. Need better solution.
|
||||
#if GTEST_MSVC6
|
||||
IsNegative<int>(-5);
|
||||
GreaterThan<int, int>(5, 0);
|
||||
#endif
|
||||
|
||||
EXPECT_PRED1(IsNegative<int>, -5);
|
||||
// Makes sure that we can handle templates with more than one
|
||||
// parameter.
|
||||
|
@ -2067,7 +2148,7 @@ TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) {
|
|||
// Tests that IsSubstring() generates the correct message when the input
|
||||
// argument type is const char*.
|
||||
TEST(IsSubstringTest, GeneratesCorrectMessageForCString) {
|
||||
EXPECT_STREQ("Value of: needle_expr\n"
|
||||
EXPECT_STREQ_USE_ESCAPED("Value of: needle_expr\n"
|
||||
" Actual: \"needle\"\n"
|
||||
"Expected: a substring of haystack_expr\n"
|
||||
"Which is: \"haystack\"",
|
||||
|
@ -2097,7 +2178,7 @@ TEST(IsSubstringTest, ReturnsCorrectResultForStdWstring) {
|
|||
// Tests that IsSubstring() generates the correct message when the input
|
||||
// argument type is ::std::wstring.
|
||||
TEST(IsSubstringTest, GeneratesCorrectMessageForWstring) {
|
||||
EXPECT_STREQ("Value of: needle_expr\n"
|
||||
EXPECT_STREQ_USE_ESCAPED("Value of: needle_expr\n"
|
||||
" Actual: L\"needle\"\n"
|
||||
"Expected: a substring of haystack_expr\n"
|
||||
"Which is: L\"haystack\"",
|
||||
|
@ -2127,7 +2208,7 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultForWideCString) {
|
|||
// Tests that IsNotSubstring() generates the correct message when the input
|
||||
// argument type is const wchar_t*.
|
||||
TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {
|
||||
EXPECT_STREQ("Value of: needle_expr\n"
|
||||
EXPECT_STREQ_USE_ESCAPED("Value of: needle_expr\n"
|
||||
" Actual: L\"needle\"\n"
|
||||
"Expected: not a substring of haystack_expr\n"
|
||||
"Which is: L\"two needles\"",
|
||||
|
@ -2148,7 +2229,7 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultsForStdString) {
|
|||
// Tests that IsNotSubstring() generates the correct message when the input
|
||||
// argument type is ::std::string.
|
||||
TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {
|
||||
EXPECT_STREQ("Value of: needle_expr\n"
|
||||
EXPECT_STREQ_USE_ESCAPED("Value of: needle_expr\n"
|
||||
" Actual: \"needle\"\n"
|
||||
"Expected: not a substring of haystack_expr\n"
|
||||
"Which is: \"two needles\"",
|
||||
|
@ -2244,6 +2325,7 @@ class FloatingPointTest : public Test {
|
|||
EXPECT_EQ(sizeof(RawType), sizeof(Bits));
|
||||
}
|
||||
|
||||
public: // Workaround for MSVC6
|
||||
static TestValues values_;
|
||||
};
|
||||
|
||||
|
@ -2277,16 +2359,22 @@ TEST_F(FloatTest, AlmostZeros) {
|
|||
// In C++Builder, names within local classes (such as used by
|
||||
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
|
||||
// scoping class. Use a static local alias as a workaround.
|
||||
static const FloatTest::TestValues& v(this->values_);
|
||||
|
||||
// In MSVC6, reference seems should be initialized by assign(=).
|
||||
static const FloatTest::TestValues& v = FloatTest::TestValues(this->values_);
|
||||
|
||||
EXPECT_FLOAT_EQ(0.0, v.close_to_positive_zero);
|
||||
EXPECT_FLOAT_EQ(-0.0, v.close_to_negative_zero);
|
||||
EXPECT_FLOAT_EQ(v.close_to_positive_zero, v.close_to_negative_zero);
|
||||
|
||||
// In MSVC6, within local classes,
|
||||
// function static variable nor static member of the scoping class
|
||||
// can be resolved. Only we can use in EXPECT_FATAL_FAILURE is
|
||||
// public static member, or some globals.
|
||||
EXPECT_FATAL_FAILURE({ // NOLINT
|
||||
ASSERT_FLOAT_EQ(v.close_to_positive_zero,
|
||||
v.further_from_negative_zero);
|
||||
}, "v.further_from_negative_zero");
|
||||
ASSERT_FLOAT_EQ(FloatTest::values_.close_to_positive_zero,
|
||||
FloatTest::values_.further_from_negative_zero);
|
||||
}, "FloatTest::values_.further_from_negative_zero");
|
||||
}
|
||||
|
||||
// Tests comparing numbers close to each other.
|
||||
|
@ -2329,7 +2417,7 @@ TEST_F(FloatTest, NaN) {
|
|||
// In C++Builder, names within local classes (such as used by
|
||||
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
|
||||
// scoping class. Use a static local alias as a workaround.
|
||||
static const FloatTest::TestValues& v(this->values_);
|
||||
static const FloatTest::TestValues& v = FloatTest::TestValues(this->values_);
|
||||
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan1),
|
||||
"v.nan1");
|
||||
|
@ -2337,9 +2425,15 @@ TEST_F(FloatTest, NaN) {
|
|||
"v.nan2");
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, v.nan1),
|
||||
"v.nan1");
|
||||
|
||||
EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(v.nan1, v.infinity),
|
||||
"v.infinity");
|
||||
|
||||
// In MSVC6, within local classes,
|
||||
// function static variable nor static member of the scoping class
|
||||
// can be resolved. Only we can use in EXPECT_FATAL_FAILURE is
|
||||
// public static member, or some globals.
|
||||
EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(
|
||||
FloatTest::values_.nan1,
|
||||
FloatTest::values_.infinity),
|
||||
"FloatTest::values_.infinity");
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
}
|
||||
|
||||
|
@ -2402,10 +2496,11 @@ TEST_F(FloatTest, FloatLEFails) {
|
|||
EXPECT_PRED_FORMAT2(FloatLE, values_.further_from_one, 1.0f);
|
||||
}, "(values_.further_from_one) <= (1.0f)");
|
||||
|
||||
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
|
||||
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) && !GTEST_MSVC6
|
||||
// Nokia's STLport crashes if we try to output infinity or NaN.
|
||||
// C++Builder gives bad results for ordered comparisons involving NaNs
|
||||
// C++Builder/MSVC6 gives bad results for ordered comparisons involving NaNs
|
||||
// due to compiler bugs.
|
||||
|
||||
EXPECT_NONFATAL_FAILURE({ // NOLINT
|
||||
EXPECT_PRED_FORMAT2(FloatLE, values_.nan1, values_.infinity);
|
||||
}, "(values_.nan1) <= (values_.infinity)");
|
||||
|
@ -2415,7 +2510,7 @@ TEST_F(FloatTest, FloatLEFails) {
|
|||
EXPECT_FATAL_FAILURE({ // NOLINT
|
||||
ASSERT_PRED_FORMAT2(FloatLE, values_.nan1, values_.nan1);
|
||||
}, "(values_.nan1) <= (values_.nan1)");
|
||||
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
|
||||
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) && !GTEST_MSVC6
|
||||
}
|
||||
|
||||
// Instantiates FloatingPointTest for testing *_DOUBLE_EQ.
|
||||
|
@ -2444,16 +2539,20 @@ TEST_F(DoubleTest, AlmostZeros) {
|
|||
// In C++Builder, names within local classes (such as used by
|
||||
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
|
||||
// scoping class. Use a static local alias as a workaround.
|
||||
static const DoubleTest::TestValues& v(this->values_);
|
||||
static const DoubleTest::TestValues& v = DoubleTest::TestValues(this->values_);
|
||||
|
||||
EXPECT_DOUBLE_EQ(0.0, v.close_to_positive_zero);
|
||||
EXPECT_DOUBLE_EQ(-0.0, v.close_to_negative_zero);
|
||||
EXPECT_DOUBLE_EQ(v.close_to_positive_zero, v.close_to_negative_zero);
|
||||
|
||||
// In MSVC6, within local classes,
|
||||
// function static variable nor static member of the scoping class
|
||||
// can be resolved. Only we can use in EXPECT_FATAL_FAILURE is
|
||||
// public static member, or some globals.
|
||||
EXPECT_FATAL_FAILURE({ // NOLINT
|
||||
ASSERT_DOUBLE_EQ(v.close_to_positive_zero,
|
||||
v.further_from_negative_zero);
|
||||
}, "v.further_from_negative_zero");
|
||||
ASSERT_DOUBLE_EQ(DoubleTest::values_.close_to_positive_zero,
|
||||
DoubleTest::values_.further_from_negative_zero);
|
||||
}, "DoubleTest::values_.further_from_negative_zero");
|
||||
}
|
||||
|
||||
// Tests comparing numbers close to each other.
|
||||
|
@ -2491,18 +2590,25 @@ TEST_F(DoubleTest, Infinity) {
|
|||
// Tests that comparing with NAN always returns false.
|
||||
TEST_F(DoubleTest, NaN) {
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
// In C++Builder, names within local classes (such as used by
|
||||
// In C++Builder and MSVC6, names within local classes (such as used by
|
||||
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
|
||||
// scoping class. Use a static local alias as a workaround.
|
||||
static const DoubleTest::TestValues& v(this->values_);
|
||||
static const DoubleTest::TestValues& v =
|
||||
DoubleTest::TestValues(this->values_);
|
||||
|
||||
// Nokia's STLport crashes if we try to output infinity or NaN.
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan1),
|
||||
"v.nan1");
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan2), "v.nan2");
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, v.nan1), "v.nan1");
|
||||
EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(v.nan1, v.infinity),
|
||||
"v.infinity");
|
||||
|
||||
// In MSVC6, within local classes,
|
||||
// function static variable nor static member of the scoping class
|
||||
// can be resolved. Only we can use in EXPECT_FATAL_FAILURE is
|
||||
// public static member, or some globals.
|
||||
EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(DoubleTest::values_.nan1,
|
||||
DoubleTest::values_.infinity),
|
||||
"DoubleTest::values_.infinity");
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
}
|
||||
|
||||
|
@ -2568,7 +2674,7 @@ TEST_F(DoubleTest, DoubleLEFails) {
|
|||
EXPECT_PRED_FORMAT2(DoubleLE, values_.further_from_one, 1.0);
|
||||
}, "(values_.further_from_one) <= (1.0)");
|
||||
|
||||
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
|
||||
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) && !GTEST_MSVC6
|
||||
// Nokia's STLport crashes if we try to output infinity or NaN.
|
||||
// C++Builder gives bad results for ordered comparisons involving NaNs
|
||||
// due to compiler bugs.
|
||||
|
@ -2581,7 +2687,7 @@ TEST_F(DoubleTest, DoubleLEFails) {
|
|||
EXPECT_FATAL_FAILURE({ // NOLINT
|
||||
ASSERT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.nan1);
|
||||
}, "(values_.nan1) <= (values_.nan1)");
|
||||
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
|
||||
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) && !GTEST_MSVC6
|
||||
}
|
||||
|
||||
|
||||
|
@ -2715,7 +2821,11 @@ class SingleEvaluationTest : public Test {
|
|||
ASSERT_NE(a_++, b_++);
|
||||
}
|
||||
|
||||
#if GTEST_MSVC6
|
||||
public:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
SingleEvaluationTest() {
|
||||
p1_ = s1_;
|
||||
p2_ = s2_;
|
||||
|
@ -2987,7 +3097,8 @@ TEST(AssertionTest, EqFailure) {
|
|||
EqFailure("foo", "bar",
|
||||
String("\"x\""), String("\"y\""),
|
||||
true).failure_message());
|
||||
EXPECT_STREQ(
|
||||
|
||||
EXPECT_STREQ_USE_ESCAPED(
|
||||
"Value of: bar\n"
|
||||
" Actual: \"y\"\n"
|
||||
"Expected: foo (ignoring case)\n"
|
||||
|
@ -3060,6 +3171,29 @@ TEST(AssertionTest, ASSERT_EQ) {
|
|||
// The NULL-detection template magic fails to compile with
|
||||
// the Nokia compiler and crashes the ARM compiler, hence
|
||||
// not testing on Symbian.
|
||||
|
||||
#if GTEST_MSVC6
|
||||
// see TEST(Pred1Test, SingleEvaluationOnFailure) for reason
|
||||
// of this hack
|
||||
class AssertionTest_MSVC6 : public testing::Test {
|
||||
public:
|
||||
static int n;
|
||||
};
|
||||
int AssertionTest_MSVC6::n = 0;
|
||||
|
||||
TEST_F(AssertionTest_MSVC6, ASSERT_EQ_NULL) {
|
||||
// A success.
|
||||
const char* p = NULL;
|
||||
ASSERT_EQ(NULL, p);
|
||||
|
||||
// A failure.
|
||||
n = 0;
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &AssertionTest_MSVC6::n),
|
||||
"Value of: &AssertionTest_MSVC6::n\n");
|
||||
}
|
||||
|
||||
#else // GTEST_MSVC6
|
||||
|
||||
TEST(AssertionTest, ASSERT_EQ_NULL) {
|
||||
// A success.
|
||||
const char* p = NULL;
|
||||
|
@ -3070,6 +3204,7 @@ TEST(AssertionTest, ASSERT_EQ_NULL) {
|
|||
EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n),
|
||||
"Value of: &n\n");
|
||||
}
|
||||
#endif // GTEST_MSVC6
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
|
||||
// Tests ASSERT_EQ(0, non_pointer). Since the literal 0 can be
|
||||
|
@ -3247,7 +3382,9 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
|
|||
// The version of gcc used in XCode 2.2 has a bug and doesn't allow
|
||||
// anonymous enums in assertions. Therefore the following test is not
|
||||
// done on Mac.
|
||||
#if !GTEST_OS_MAC
|
||||
// Additionaly, template initialization for anonymous enums seems not
|
||||
// be supported in MSVC6 also.
|
||||
#if !GTEST_OS_MAC && !GTEST_MSVC6
|
||||
|
||||
// Tests using assertions with anonymous enums.
|
||||
enum {
|
||||
|
@ -3292,7 +3429,7 @@ TEST(AssertionTest, AnonymousEnum) {
|
|||
"Value of: CASE_B");
|
||||
}
|
||||
|
||||
#endif // !GTEST_OS_MAC
|
||||
#endif // !GTEST_OS_MAC && !GTEST_MSVC6
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
|
||||
|
@ -3509,9 +3646,27 @@ void ThrowAString() {
|
|||
// Test that the exception assertion macros compile and work with const
|
||||
// type qualifier.
|
||||
TEST(AssertionSyntaxTest, WorksWithConst) {
|
||||
#if GTEST_MSVC6
|
||||
// MSVC6 can't catch "pointer-to-const" as "reference to pointer-to-const".
|
||||
// for example
|
||||
/*
|
||||
try{
|
||||
throw "foo";
|
||||
}catch(const char *&){
|
||||
printf("String catched\n"); // in MSVC6 this code can not be reached.
|
||||
}catch(char *&){
|
||||
printf("String catched (non-const)\n"); // in MSVC66, catched here
|
||||
}
|
||||
*/
|
||||
// so you should expect pointer-to-non-const...
|
||||
ASSERT_THROW(ThrowAString(), char *);
|
||||
EXPECT_THROW(ThrowAString(), char *);
|
||||
|
||||
#else
|
||||
ASSERT_THROW(ThrowAString(), const char*);
|
||||
|
||||
EXPECT_THROW(ThrowAString(), const char*);
|
||||
#endif // GTEST_MSVC6
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
@ -3775,6 +3930,37 @@ TEST(StreamableToStringTest, NullCString) {
|
|||
// Tests using streamable values as assertion messages.
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
|
||||
#if GTEST_MSVC6
|
||||
// see TEST(Pred1Test, SingleEvaluationOnFailure) for reason
|
||||
// of this hack
|
||||
class StreamableTest_MSVC6 : public testing::Test {
|
||||
public:
|
||||
static std::string str;
|
||||
static std::string string_with_nul;
|
||||
};
|
||||
std::string StreamableTest_MSVC6::str
|
||||
= "This failure message is a std::string, and is expected";
|
||||
std::string StreamableTest_MSVC6::string_with_nul = "";
|
||||
|
||||
|
||||
TEST_F(StreamableTest_MSVC6, string) {
|
||||
EXPECT_FATAL_FAILURE(FAIL() << StreamableTest_MSVC6::str,
|
||||
StreamableTest_MSVC6::str.c_str());
|
||||
}
|
||||
|
||||
TEST_F(StreamableTest_MSVC6, stringWithEmbeddedNUL) {
|
||||
static const char char_array_with_nul[] =
|
||||
"Here's a NUL\0 and some more string";
|
||||
StreamableTest_MSVC6::string_with_nul = std::string(char_array_with_nul,
|
||||
sizeof(char_array_with_nul)
|
||||
- 1); // drops the trailing NUL
|
||||
EXPECT_FATAL_FAILURE(FAIL() << StreamableTest_MSVC6::string_with_nul,
|
||||
"Here's a NUL\\0 and some more string");
|
||||
}
|
||||
|
||||
|
||||
#else // GTEST_MSVC6
|
||||
// Tests using std::string as an assertion message.
|
||||
TEST(StreamableTest, string) {
|
||||
static const std::string str(
|
||||
|
@ -3795,6 +3981,8 @@ TEST(StreamableTest, stringWithEmbeddedNUL) {
|
|||
"Here's a NUL\\0 and some more string");
|
||||
}
|
||||
|
||||
#endif // GTEST_MSVC6
|
||||
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
// Tests that we can output a NUL char.
|
||||
|
@ -3900,6 +4088,75 @@ TEST(EqAssertionTest, Char) {
|
|||
"ch");
|
||||
}
|
||||
|
||||
#if GTEST_MSVC6
|
||||
// see TEST(Pred1Test, SingleEvaluationOnFailure) for reason
|
||||
// of this hack
|
||||
class EqAssertionTest_MSVC6 : public testing::Test {
|
||||
public:
|
||||
static wchar_t wchar;
|
||||
static ::std::string str1;
|
||||
static ::std::string str2;
|
||||
static ::std::string str3;
|
||||
};
|
||||
wchar_t EqAssertionTest_MSVC6::wchar = L'b';
|
||||
::std::string EqAssertionTest_MSVC6::str1 = "";
|
||||
::std::string EqAssertionTest_MSVC6::str2 = "";
|
||||
::std::string EqAssertionTest_MSVC6::str3 = "";
|
||||
|
||||
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
|
||||
TEST_F(EqAssertionTest_MSVC6, WideChar) {
|
||||
EXPECT_EQ(L'b', L'b');
|
||||
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\0', L'x'),
|
||||
"Value of: L'x'\n"
|
||||
" Actual: L'x' (120, 0x78)\n"
|
||||
"Expected: L'\0'\n"
|
||||
"Which is: L'\0' (0, 0x0)");
|
||||
|
||||
wchar = L'b';
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'a', wchar),
|
||||
"wchar");
|
||||
wchar = L'\x8119';
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(L'\x8120', EqAssertionTest_MSVC6::wchar),
|
||||
"Value of: EqAssertionTest_MSVC6::wchar");
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
|
||||
TEST_F(EqAssertionTest_MSVC6, StdString) {
|
||||
// Compares a const char* to an std::string that has identical
|
||||
// content.
|
||||
ASSERT_EQ("Test", ::std::string("Test"));
|
||||
|
||||
// Compares two identical std::strings.
|
||||
str1 = "A * in the middle";
|
||||
str2 = str1;
|
||||
EXPECT_EQ(str1, str2);
|
||||
|
||||
// Compares a const char* to an std::string that has different
|
||||
// content
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_EQ("Test", ::std::string("test")),
|
||||
"::std::string(\"test\")");
|
||||
|
||||
// Compares an std::string to a char* that has different content.
|
||||
char* const p1 = const_cast<char*>("foo");
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::std::string("bar"), p1),
|
||||
"p1");
|
||||
|
||||
// Compares two std::strings that have different contents, one of
|
||||
// which having a NUL character in the middle. This should fail.
|
||||
str3 = str1;
|
||||
str3.at(2) = '\0';
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(EqAssertionTest_MSVC6::str1,
|
||||
EqAssertionTest_MSVC6::str3),
|
||||
"Value of: EqAssertionTest_MSVC6::str3\n"
|
||||
" Actual: \"A \\0 in the middle\"");
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
#else // GTEST_MSVC6
|
||||
|
||||
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
|
||||
TEST(EqAssertionTest, WideChar) {
|
||||
EXPECT_EQ(L'b', L'b');
|
||||
|
@ -3952,6 +4209,8 @@ TEST(EqAssertionTest, StdString) {
|
|||
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
#endif // GTEST_MSVC6
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
|
||||
// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.
|
||||
|
@ -5531,15 +5790,27 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
|
|||
|
||||
// Verifies that StaticAssertTypeEq works in a namespace scope.
|
||||
|
||||
#if GTEST_MSVC6
|
||||
// workaround for MSVC6, which does not allow to import template function by
|
||||
// "using functionname".
|
||||
static bool dummy1 = testing::StaticAssertTypeEq<bool, bool>();
|
||||
static bool dummy2 = testing::StaticAssertTypeEq<const int, const int>();
|
||||
|
||||
#else
|
||||
|
||||
static bool dummy1 = StaticAssertTypeEq<bool, bool>();
|
||||
static bool dummy2 = StaticAssertTypeEq<const int, const int>();
|
||||
|
||||
#endif // GTEST_MSVC6
|
||||
|
||||
|
||||
|
||||
// Verifies that StaticAssertTypeEq works in a class.
|
||||
|
||||
template <typename T>
|
||||
class StaticAssertTypeEqTestHelper {
|
||||
public:
|
||||
StaticAssertTypeEqTestHelper() { StaticAssertTypeEq<bool, T>(); }
|
||||
StaticAssertTypeEqTestHelper() { testing::StaticAssertTypeEq<bool, T>(); }
|
||||
};
|
||||
|
||||
TEST(StaticAssertTypeEqTest, WorksInClass) {
|
||||
|
@ -5551,8 +5822,8 @@ TEST(StaticAssertTypeEqTest, WorksInClass) {
|
|||
typedef int IntAlias;
|
||||
|
||||
TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
|
||||
StaticAssertTypeEq<int, IntAlias>();
|
||||
StaticAssertTypeEq<int*, IntAlias*>();
|
||||
testing::StaticAssertTypeEq<int, IntAlias>();
|
||||
testing::StaticAssertTypeEq<int*, IntAlias*>();
|
||||
}
|
||||
|
||||
TEST(ThreadLocalTest, DefaultConstructor) {
|
||||
|
|
Loading…
Add table
Reference in a new issue