Makes gtest wokr on MinGW (by Vlad Losev); removes unused linked_ptr::release() method (by Zhanyong Wan).
This commit is contained in:
parent
9c48242258
commit
c18438ca29
@ -172,15 +172,6 @@ class linked_ptr {
|
||||
T* get() const { return value_; }
|
||||
T* operator->() const { return value_; }
|
||||
T& operator*() const { return *value_; }
|
||||
// Release ownership of the pointed object and returns it.
|
||||
// Sole ownership by this linked_ptr object is required.
|
||||
T* release() {
|
||||
bool last = link_.depart();
|
||||
assert(last);
|
||||
T* v = value_;
|
||||
value_ = NULL;
|
||||
return v;
|
||||
}
|
||||
|
||||
bool operator==(T* p) const { return value_ == p; }
|
||||
bool operator!=(T* p) const { return value_ != p; }
|
||||
|
@ -526,11 +526,11 @@ bool DeathTestImpl::Passed(bool status_ok) {
|
||||
//
|
||||
class WindowsDeathTest : public DeathTestImpl {
|
||||
public:
|
||||
WindowsDeathTest(const char* statement,
|
||||
const RE* regex,
|
||||
WindowsDeathTest(const char* a_statement,
|
||||
const RE* a_regex,
|
||||
const char* file,
|
||||
int line)
|
||||
: DeathTestImpl(statement, regex), file_(file), line_(line) {}
|
||||
: DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}
|
||||
|
||||
// All of these virtual functions are inherited from DeathTest.
|
||||
virtual int Wait();
|
||||
@ -587,12 +587,12 @@ int WindowsDeathTest::Wait() {
|
||||
GTEST_DEATH_TEST_CHECK_(
|
||||
WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),
|
||||
INFINITE));
|
||||
DWORD status;
|
||||
GTEST_DEATH_TEST_CHECK_(::GetExitCodeProcess(child_handle_.Get(), &status)
|
||||
!= FALSE);
|
||||
DWORD status_code;
|
||||
GTEST_DEATH_TEST_CHECK_(
|
||||
::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);
|
||||
child_handle_.Reset();
|
||||
set_status(static_cast<int>(status));
|
||||
return this->status();
|
||||
set_status(static_cast<int>(status_code));
|
||||
return status();
|
||||
}
|
||||
|
||||
// The AssumeRole process for a Windows death test. It creates a child
|
||||
|
@ -994,7 +994,7 @@ TEST(AutoHandleTest, AutoHandleWorks) {
|
||||
typedef unsigned __int64 BiggestParsable;
|
||||
typedef signed __int64 BiggestSignedParsable;
|
||||
const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
|
||||
const BiggestParsable kBiggestSignedParsableMax = LLONG_MAX;
|
||||
const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
|
||||
#else
|
||||
typedef unsigned long long BiggestParsable;
|
||||
typedef signed long long BiggestSignedParsable;
|
||||
|
@ -50,8 +50,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// hash_map and hash_set are available on Windows.
|
||||
#if GTEST_OS_WINDOWS
|
||||
// hash_map and hash_set are available under Visual C++.
|
||||
#if _MSC_VER
|
||||
#define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
||||
#include <hash_map> // NOLINT
|
||||
#define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
||||
@ -212,17 +212,15 @@ using ::std::tr1::make_tuple;
|
||||
using ::std::tr1::tuple;
|
||||
#endif
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#if _MSC_VER
|
||||
// MSVC defines the following classes in the ::stdext namespace while
|
||||
// gcc defines them in the :: namespace. Note that they are not part
|
||||
// of the C++ standard.
|
||||
|
||||
using ::stdext::hash_map;
|
||||
using ::stdext::hash_set;
|
||||
using ::stdext::hash_multimap;
|
||||
using ::stdext::hash_multiset;
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
#endif
|
||||
|
||||
// Prints a value to a string using the universal value printer. This
|
||||
// is a helper for testing UniversalPrinter<T>::Print() for various types.
|
||||
@ -333,8 +331,8 @@ TEST(PrintBuiltInTypeTest, Wchar_t) {
|
||||
EXPECT_EQ("L'\\xFF' (255)", Print(L'\xFF'));
|
||||
EXPECT_EQ("L' ' (32, 0x20)", Print(L' '));
|
||||
EXPECT_EQ("L'a' (97, 0x61)", Print(L'a'));
|
||||
EXPECT_EQ("L'\\x576' (1398)", Print(L'\x576'));
|
||||
EXPECT_EQ("L'\\xC74D' (51021)", Print(L'\xC74D'));
|
||||
EXPECT_EQ("L'\\x576' (1398)", Print(static_cast<wchar_t>(0x576)));
|
||||
EXPECT_EQ("L'\\xC74D' (51021)", Print(static_cast<wchar_t>(0xC74D)));
|
||||
}
|
||||
|
||||
// Test that Int64 provides more storage than wchar_t.
|
||||
@ -440,10 +438,11 @@ TEST(PrintWideCStringTest, Null) {
|
||||
|
||||
// Tests that wide C strings are escaped properly.
|
||||
TEST(PrintWideCStringTest, EscapesProperly) {
|
||||
const wchar_t* p = L"'\"\?\\\a\b\f\n\r\t\v\xD3\x576\x8D3\xC74D a";
|
||||
EXPECT_EQ(PrintPointer(p) + " pointing to L\"'\\\"\\?\\\\\\a\\b\\f"
|
||||
const wchar_t s[] = {'\'', '"', '\?', '\\', '\a', '\b', '\f', '\n', '\r',
|
||||
'\t', '\v', 0xD3, 0x576, 0x8D3, 0xC74D, ' ', 'a', '\0'};
|
||||
EXPECT_EQ(PrintPointer(s) + " pointing to L\"'\\\"\\?\\\\\\a\\b\\f"
|
||||
"\\n\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\"",
|
||||
Print(p));
|
||||
Print(static_cast<const wchar_t*>(s)));
|
||||
}
|
||||
#endif // native wchar_t
|
||||
|
||||
|
@ -372,7 +372,11 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
|
||||
EXPECT_STREQ("\xC3\x93", CodePointToUtf8(L'\xD3', buffer));
|
||||
|
||||
// 101 0111 0110 => 110-10101 10-110110
|
||||
EXPECT_STREQ("\xD5\xB6", CodePointToUtf8(L'\x576', buffer));
|
||||
// Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints
|
||||
// in wide strings and wide chars. In order to accomodate them, we have to
|
||||
// introduce such character constants as integers.
|
||||
EXPECT_STREQ("\xD5\xB6",
|
||||
CodePointToUtf8(static_cast<wchar_t>(0x576), buffer));
|
||||
}
|
||||
|
||||
// Tests that Unicode code-points that have 12 to 16 bits are encoded
|
||||
@ -380,10 +384,12 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
|
||||
TEST(CodePointToUtf8Test, CanEncode12To16Bits) {
|
||||
char buffer[32];
|
||||
// 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011
|
||||
EXPECT_STREQ("\xE0\xA3\x93", CodePointToUtf8(L'\x8D3', buffer));
|
||||
EXPECT_STREQ("\xE0\xA3\x93",
|
||||
CodePointToUtf8(static_cast<wchar_t>(0x8D3), buffer));
|
||||
|
||||
// 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101
|
||||
EXPECT_STREQ("\xEC\x9D\x8D", CodePointToUtf8(L'\xC74D', buffer));
|
||||
EXPECT_STREQ("\xEC\x9D\x8D",
|
||||
CodePointToUtf8(static_cast<wchar_t>(0xC74D), buffer));
|
||||
}
|
||||
|
||||
#if !GTEST_WIDE_STRING_USES_UTF16_
|
||||
@ -438,20 +444,23 @@ TEST(WideStringToUtf8Test, CanEncode8To11Bits) {
|
||||
EXPECT_STREQ("\xC3\x93", WideStringToUtf8(L"\xD3", -1).c_str());
|
||||
|
||||
// 101 0111 0110 => 110-10101 10-110110
|
||||
EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(L"\x576", 1).c_str());
|
||||
EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(L"\x576", -1).c_str());
|
||||
const wchar_t s[] = { 0x576, '\0' };
|
||||
EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(s, 1).c_str());
|
||||
EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(s, -1).c_str());
|
||||
}
|
||||
|
||||
// Tests that Unicode code-points that have 12 to 16 bits are encoded
|
||||
// as 1110xxxx 10xxxxxx 10xxxxxx.
|
||||
TEST(WideStringToUtf8Test, CanEncode12To16Bits) {
|
||||
// 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011
|
||||
EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(L"\x8D3", 1).c_str());
|
||||
EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(L"\x8D3", -1).c_str());
|
||||
const wchar_t s1[] = { 0x8D3, '\0' };
|
||||
EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(s1, 1).c_str());
|
||||
EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(s1, -1).c_str());
|
||||
|
||||
// 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101
|
||||
EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(L"\xC74D", 1).c_str());
|
||||
EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(L"\xC74D", -1).c_str());
|
||||
const wchar_t s2[] = { 0xC74D, '\0' };
|
||||
EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(s2, 1).c_str());
|
||||
EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(s2, -1).c_str());
|
||||
}
|
||||
|
||||
// Tests that the conversion stops when the function encounters \0 character.
|
||||
@ -465,7 +474,6 @@ TEST(WideStringToUtf8Test, StopsWhenLengthLimitReached) {
|
||||
EXPECT_STREQ("ABC", WideStringToUtf8(L"ABCDEF", 3).c_str());
|
||||
}
|
||||
|
||||
|
||||
#if !GTEST_WIDE_STRING_USES_UTF16_
|
||||
// Tests that Unicode code-points that have 17 to 21 bits are encoded
|
||||
// as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. This code may not compile
|
||||
@ -489,25 +497,29 @@ TEST(WideStringToUtf8Test, CanEncodeInvalidCodePoint) {
|
||||
// Tests that surrogate pairs are encoded correctly on the systems using
|
||||
// UTF-16 encoding in the wide strings.
|
||||
TEST(WideStringToUtf8Test, CanEncodeValidUtf16SUrrogatePairs) {
|
||||
EXPECT_STREQ("\xF0\x90\x90\x80",
|
||||
WideStringToUtf8(L"\xD801\xDC00", -1).c_str());
|
||||
const wchar_t s[] = { 0xD801, 0xDC00, '\0' };
|
||||
EXPECT_STREQ("\xF0\x90\x90\x80", WideStringToUtf8(s, -1).c_str());
|
||||
}
|
||||
|
||||
// Tests that encoding an invalid UTF-16 surrogate pair
|
||||
// generates the expected result.
|
||||
TEST(WideStringToUtf8Test, CanEncodeInvalidUtf16SurrogatePair) {
|
||||
// Leading surrogate is at the end of the string.
|
||||
EXPECT_STREQ("\xED\xA0\x80", WideStringToUtf8(L"\xD800", -1).c_str());
|
||||
const wchar_t s1[] = { 0xD800, '\0' };
|
||||
EXPECT_STREQ("\xED\xA0\x80", WideStringToUtf8(s1, -1).c_str());
|
||||
// Leading surrogate is not followed by the trailing surrogate.
|
||||
EXPECT_STREQ("\xED\xA0\x80$", WideStringToUtf8(L"\xD800$", -1).c_str());
|
||||
const wchar_t s2[] = { 0xD800, 'M', '\0' };
|
||||
EXPECT_STREQ("\xED\xA0\x80M", WideStringToUtf8(s2, -1).c_str());
|
||||
// Trailing surrogate appearas without a leading surrogate.
|
||||
EXPECT_STREQ("\xED\xB0\x80PQR", WideStringToUtf8(L"\xDC00PQR", -1).c_str());
|
||||
const wchar_t s3[] = { 0xDC00, 'P', 'Q', 'R', '\0' };
|
||||
EXPECT_STREQ("\xED\xB0\x80PQR", WideStringToUtf8(s3, -1).c_str());
|
||||
}
|
||||
#endif // !GTEST_WIDE_STRING_USES_UTF16_
|
||||
|
||||
// Tests that codepoint concatenation works correctly.
|
||||
#if !GTEST_WIDE_STRING_USES_UTF16_
|
||||
TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {
|
||||
const wchar_t s[] = { 0x108634, 0xC74D, '\n', 0x576, 0x8D3, 0x108634, '\0'};
|
||||
EXPECT_STREQ(
|
||||
"\xF4\x88\x98\xB4"
|
||||
"\xEC\x9D\x8D"
|
||||
@ -515,13 +527,14 @@ TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {
|
||||
"\xD5\xB6"
|
||||
"\xE0\xA3\x93"
|
||||
"\xF4\x88\x98\xB4",
|
||||
WideStringToUtf8(L"\x108634\xC74D\n\x576\x8D3\x108634", -1).c_str());
|
||||
WideStringToUtf8(s, -1).c_str());
|
||||
}
|
||||
#else
|
||||
TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {
|
||||
const wchar_t s[] = { 0xC74D, '\n', 0x576, 0x8D3, '\0'};
|
||||
EXPECT_STREQ(
|
||||
"\xEC\x9D\x8D" "\n" "\xD5\xB6" "\xE0\xA3\x93",
|
||||
WideStringToUtf8(L"\xC74D\n\x576\x8D3", -1).c_str());
|
||||
WideStringToUtf8(s, -1).c_str());
|
||||
}
|
||||
#endif // !GTEST_WIDE_STRING_USES_UTF16_
|
||||
|
||||
@ -4519,8 +4532,8 @@ TEST(EqAssertionTest, WideChar) {
|
||||
wchar = L'b';
|
||||
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'a', wchar),
|
||||
"wchar");
|
||||
wchar = L'\x8119';
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(L'\x8120', wchar),
|
||||
wchar = 0x8119;
|
||||
EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),
|
||||
"Value of: wchar");
|
||||
}
|
||||
|
||||
@ -4558,20 +4571,22 @@ TEST(EqAssertionTest, StdString) {
|
||||
|
||||
// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.
|
||||
TEST(EqAssertionTest, StdWideString) {
|
||||
// Compares an std::wstring to a const wchar_t* that has identical
|
||||
// content.
|
||||
EXPECT_EQ(::std::wstring(L"Test\x8119"), L"Test\x8119");
|
||||
|
||||
// Compares two identical std::wstrings.
|
||||
const ::std::wstring wstr1(L"A * in the middle");
|
||||
const ::std::wstring wstr2(wstr1);
|
||||
ASSERT_EQ(wstr1, wstr2);
|
||||
|
||||
// Compares an std::wstring to a const wchar_t* that has identical
|
||||
// content.
|
||||
const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\0' };
|
||||
EXPECT_EQ(::std::wstring(kTestX8119), kTestX8119);
|
||||
|
||||
// Compares an std::wstring to a const wchar_t* that has different
|
||||
// content.
|
||||
const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\0' };
|
||||
EXPECT_NONFATAL_FAILURE({ // NOLINT
|
||||
EXPECT_EQ(::std::wstring(L"Test\x8119"), L"Test\x8120");
|
||||
}, "L\"Test\\x8120\"");
|
||||
EXPECT_EQ(::std::wstring(kTestX8119), kTestX8120);
|
||||
}, "kTestX8120");
|
||||
|
||||
// Compares two std::wstrings that have different contents, one of
|
||||
// which having a NUL character in the middle.
|
||||
@ -4623,18 +4638,20 @@ TEST(EqAssertionTest, GlobalString) {
|
||||
|
||||
// Tests using ::wstring values in {EXPECT|ASSERT}_EQ.
|
||||
TEST(EqAssertionTest, GlobalWideString) {
|
||||
// Compares a const wchar_t* to a ::wstring that has identical content.
|
||||
ASSERT_EQ(L"Test\x8119", ::wstring(L"Test\x8119"));
|
||||
|
||||
// Compares two identical ::wstrings.
|
||||
static const ::wstring wstr1(L"A * in the middle");
|
||||
static const ::wstring wstr2(wstr1);
|
||||
EXPECT_EQ(wstr1, wstr2);
|
||||
|
||||
// Compares a const wchar_t* to a ::wstring that has identical content.
|
||||
const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\0' };
|
||||
ASSERT_EQ(kTestX8119, ::wstring(kTestX8119));
|
||||
|
||||
// Compares a const wchar_t* to a ::wstring that has different
|
||||
// content.
|
||||
const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\0' };
|
||||
EXPECT_NONFATAL_FAILURE({ // NOLINT
|
||||
EXPECT_EQ(L"Test\x8120", ::wstring(L"Test\x8119"));
|
||||
EXPECT_EQ(kTestX8120, ::wstring(kTestX8119));
|
||||
}, "Test\\x8119");
|
||||
|
||||
// Compares a wchar_t* to a ::wstring that has different content.
|
||||
|
Loading…
Reference in New Issue
Block a user