Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
cfcbc298
Commit
cfcbc298
authored
Feb 03, 2010
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds Solaris support (by Hady Zalek)
parent
8d373310
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
115 additions
and
61 deletions
+115
-61
gtest-typed-test.h
include/gtest/gtest-typed-test.h
+8
-2
gtest-port.h
include/gtest/internal/gtest-port.h
+22
-16
gtest-tuple.h
include/gtest/internal/gtest-tuple.h
+2
-1
gtest-tuple.h.pump
include/gtest/internal/gtest-tuple.h.pump
+2
-1
gtest-filepath.cc
src/gtest-filepath.cc
+2
-1
gtest-port.cc
src/gtest-port.cc
+12
-5
gtest-typed-test.cc
src/gtest-typed-test.cc
+12
-0
gtest-filepath_test.cc
test/gtest-filepath_test.cc
+26
-25
gtest_unittest.cc
test/gtest_unittest.cc
+29
-10
No files found.
include/gtest/gtest-typed-test.h
View file @
cfcbc298
...
@@ -159,8 +159,11 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
...
@@ -159,8 +159,11 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
// given test case.
// given test case.
#define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
#define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
// The 'Types' template argument below must have spaces around it
// since some compilers may choke on '>>' when passing a template
// instance (e.g. Types<int>)
#define TYPED_TEST_CASE(CaseName, Types) \
#define TYPED_TEST_CASE(CaseName, Types) \
typedef ::testing::internal::TypeList<
Types
>::type \
typedef ::testing::internal::TypeList<
Types
>::type \
GTEST_TYPE_PARAMS_(CaseName)
GTEST_TYPE_PARAMS_(CaseName)
#define TYPED_TEST(CaseName, TestName) \
#define TYPED_TEST(CaseName, TestName) \
...
@@ -241,11 +244,14 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
...
@@ -241,11 +244,14 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
__FILE__, __LINE__, #__VA_ARGS__)
__FILE__, __LINE__, #__VA_ARGS__)
// The 'Types' template argument below must have spaces around it
// since some compilers may choke on '>>' when passing a template
// instance (e.g. Types<int>)
#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
bool gtest_##Prefix##_##CaseName = \
bool gtest_##Prefix##_##CaseName = \
::testing::internal::TypeParameterizedTestCase<CaseName, \
::testing::internal::TypeParameterizedTestCase<CaseName, \
GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
::testing::internal::TypeList<
Types
>::type>::Register(\
::testing::internal::TypeList<
Types
>::type>::Register(\
#Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
#Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_HAS_TYPED_TEST_P
...
...
include/gtest/internal/gtest-port.h
View file @
cfcbc298
...
@@ -42,6 +42,8 @@
...
@@ -42,6 +42,8 @@
//
//
// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
// is/isn't available.
// is/isn't available.
// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
// are enabled.
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
// is/isn't available (some systems define
// is/isn't available (some systems define
// ::string, which is different to std::string).
// ::string, which is different to std::string).
...
@@ -242,9 +244,9 @@
...
@@ -242,9 +244,9 @@
#endif // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC ||
#endif // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC ||
// GTEST_OS_SYMBIAN || GTEST_OS_SOLARIS
// GTEST_OS_SYMBIAN || GTEST_OS_SOLARIS
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
#ifndef GTEST_HAS_EXCEPTIONS
//
otherwise.
//
The user didn't tell us whether exceptions are enabled, so we need
// to figure it out.
#if defined(_MSC_VER) || defined(__BORLANDC__)
#if defined(_MSC_VER) || defined(__BORLANDC__)
// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
// macro to enable exceptions, so we'll do the same.
// macro to enable exceptions, so we'll do the same.
...
@@ -253,16 +255,20 @@
...
@@ -253,16 +255,20 @@
#define _HAS_EXCEPTIONS 1
#define _HAS_EXCEPTIONS 1
#endif // _HAS_EXCEPTIONS
#endif // _HAS_EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
#else // The compiler is not MSVC or C++Builder.
#elif defined(__GNUC__) && __EXCEPTIONS
// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. For
// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
// other compilers, we assume exceptions are disabled to be
#define GTEST_HAS_EXCEPTIONS 1
// conservative.
#elif defined(__SUNPRO_CC)
#if defined(__GNUC__) && __EXCEPTIONS
// Sun Pro CC supports exceptions. However, there is no compile-time way of
// detecting whether they are enabled or not. Therefore, we assume that
// they are enabled unless the user tells us otherwise.
#define GTEST_HAS_EXCEPTIONS 1
#define GTEST_HAS_EXCEPTIONS 1
#else
#else
// For other compilers, we assume exceptions are disabled to be
// conservative.
#define GTEST_HAS_EXCEPTIONS 0
#define GTEST_HAS_EXCEPTIONS 0
#endif // defined(__GNUC__) && __EXCEPTIONS
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
#endif // GTEST_HAS_EXCEPTIONS
#if !defined(GTEST_HAS_STD_STRING)
#if !defined(GTEST_HAS_STD_STRING)
// Even though we don't use this macro any longer, we keep it in case
// Even though we don't use this macro any longer, we keep it in case
...
@@ -340,7 +346,7 @@
...
@@ -340,7 +346,7 @@
// Determines whether <pthread.h> is available.
// Determines whether <pthread.h> is available.
#ifndef GTEST_HAS_PTHREAD
#ifndef GTEST_HAS_PTHREAD
// The user didn't tell us, so we need to figure it out.
// The user didn't tell us, so we need to figure it out.
#define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC)
#define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC
|| GTEST_OS_SOLARIS
)
#endif // GTEST_HAS_PTHREAD
#endif // GTEST_HAS_PTHREAD
// Determines whether Google Test can use tr1/tuple. You can define
// Determines whether Google Test can use tr1/tuple. You can define
...
@@ -446,7 +452,7 @@
...
@@ -446,7 +452,7 @@
// Google Test does not support death tests for VC 7.1 and earlier as
// Google Test does not support death tests for VC 7.1 and earlier as
// abort() in a VC 7.1 application compiled as GUI in debug config
// abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
// pops up a dialog window that cannot be suppressed programmatically.
#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN ||
GTEST_OS_SOLARIS ||
\
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
#define GTEST_HAS_DEATH_TEST 1
#define GTEST_HAS_DEATH_TEST 1
#include <vector> // NOLINT
#include <vector> // NOLINT
...
@@ -462,12 +468,12 @@
...
@@ -462,12 +468,12 @@
// Determines whether to support type-driven tests.
// Determines whether to support type-driven tests.
// Typed tests need <typeinfo> and variadic macros, which
gcc and VC
// Typed tests need <typeinfo> and variadic macros, which
GCC, VC++ 8.0, and
//
8.0+
support.
//
Sun Pro CC
support.
#if defined(__GNUC__) || (_MSC_VER >= 1400)
#if defined(__GNUC__) || (_MSC_VER >= 1400)
|| defined(__SUNPRO_CC)
#define GTEST_HAS_TYPED_TEST 1
#define GTEST_HAS_TYPED_TEST 1
#define GTEST_HAS_TYPED_TEST_P 1
#define GTEST_HAS_TYPED_TEST_P 1
#endif
// defined(__GNUC__) || (_MSC_VER >= 1400)
#endif
// Determines whether to support Combine(). This only makes sense when
// Determines whether to support Combine(). This only makes sense when
// value-parameterized tests are enabled.
// value-parameterized tests are enabled.
...
@@ -923,7 +929,7 @@ inline const char* GetEnv(const char* name) {
...
@@ -923,7 +929,7 @@ inline const char* GetEnv(const char* name) {
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
// We are on Windows CE, which has no environment variables.
// We are on Windows CE, which has no environment variables.
return
NULL
;
return
NULL
;
#elif defined(__BORLANDC__)
#elif defined(__BORLANDC__)
|| defined(__SunOS_5_8) || defined(__SunOS_5_9)
// Environment variables which we programmatically clear will be set to the
// Environment variables which we programmatically clear will be set to the
// empty string rather than unset (NULL). Handle that case.
// empty string rather than unset (NULL). Handle that case.
const
char
*
const
env
=
getenv
(
name
);
const
char
*
const
env
=
getenv
(
name
);
...
...
include/gtest/internal/gtest-tuple.h
View file @
cfcbc298
...
@@ -42,7 +42,8 @@
...
@@ -42,7 +42,8 @@
// tuple template as a friend (it complains that tuple is redefined). This
// tuple template as a friend (it complains that tuple is redefined). This
// hack bypasses the bug by declaring the members that should otherwise be
// hack bypasses the bug by declaring the members that should otherwise be
// private as public.
// private as public.
#if defined(__SYMBIAN32__)
// Sun Studio versions < 12 also have the above bug.
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#else
#else
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
...
...
include/gtest/internal/gtest-tuple.h.pump
View file @
cfcbc298
...
@@ -43,7 +43,8 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
...
@@ -43,7 +43,8 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
// tuple template as a friend (it complains that tuple is redefined). This
// tuple template as a friend (it complains that tuple is redefined). This
// hack bypasses the bug by declaring the members that should otherwise be
// hack bypasses the bug by declaring the members that should otherwise be
// private as public.
// private as public.
#if defined(__SYMBIAN32__)
// Sun Studio versions < 12 also have the above bug.
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#else
#else
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
...
...
src/gtest-filepath.cc
View file @
cfcbc298
...
@@ -342,9 +342,10 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
...
@@ -342,9 +342,10 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
:
*
this
;
:
*
this
;
}
}
//
Normalize r
emoves any redundant separators that might be in the pathname.
//
R
emoves any redundant separators that might be in the pathname.
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..".
// redundancies that might be in a pathname involving "." or "..".
// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share).
void
FilePath
::
Normalize
()
{
void
FilePath
::
Normalize
()
{
if
(
pathname_
.
c_str
()
==
NULL
)
{
if
(
pathname_
.
c_str
()
==
NULL
)
{
pathname_
=
""
;
pathname_
=
""
;
...
...
src/gtest-port.cc
View file @
cfcbc298
...
@@ -111,8 +111,14 @@ size_t GetThreadCount() {
...
@@ -111,8 +111,14 @@ size_t GetThreadCount() {
// Implements RE. Currently only needed for death tests.
// Implements RE. Currently only needed for death tests.
RE
::~
RE
()
{
RE
::~
RE
()
{
regfree
(
&
partial_regex_
);
if
(
is_valid_
)
{
regfree
(
&
full_regex_
);
// regfree'ing an invalid regex might crash because the content
// of the regex is undefined. Since the regex's are essentially
// the same, one cannot be valid (or invalid) without the other
// being so too.
regfree
(
&
partial_regex_
);
regfree
(
&
full_regex_
);
}
free
(
const_cast
<
char
*>
(
pattern_
));
free
(
const_cast
<
char
*>
(
pattern_
));
}
}
...
@@ -152,9 +158,10 @@ void RE::Init(const char* regex) {
...
@@ -152,9 +158,10 @@ void RE::Init(const char* regex) {
// Some implementation of POSIX regex (e.g. on at least some
// Some implementation of POSIX regex (e.g. on at least some
// versions of Cygwin) doesn't accept the empty string as a valid
// versions of Cygwin) doesn't accept the empty string as a valid
// regex. We change it to an equivalent form "()" to be safe.
// regex. We change it to an equivalent form "()" to be safe.
const
char
*
const
partial_regex
=
(
*
regex
==
'\0'
)
?
"()"
:
regex
;
if
(
is_valid_
)
{
is_valid_
=
(
regcomp
(
&
partial_regex_
,
partial_regex
,
REG_EXTENDED
)
==
0
)
const
char
*
const
partial_regex
=
(
*
regex
==
'\0'
)
?
"()"
:
regex
;
&&
is_valid_
;
is_valid_
=
regcomp
(
&
partial_regex_
,
partial_regex
,
REG_EXTENDED
)
==
0
;
}
EXPECT_TRUE
(
is_valid_
)
EXPECT_TRUE
(
is_valid_
)
<<
"Regular expression
\"
"
<<
regex
<<
"Regular expression
\"
"
<<
regex
<<
"
\"
is not a valid POSIX Extended regular expression."
;
<<
"
\"
is not a valid POSIX Extended regular expression."
;
...
...
src/gtest-typed-test.cc
View file @
cfcbc298
...
@@ -37,6 +37,14 @@ namespace internal {
...
@@ -37,6 +37,14 @@ namespace internal {
#if GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
// Skips to the first non-space char in str. Returns an empty string if str
// contains only whitespace characters.
static
const
char
*
SkipSpaces
(
const
char
*
str
)
{
while
(
isspace
(
*
str
))
str
++
;
return
str
;
}
// Verifies that registered_tests match the test names in
// Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or
// defined_test_names_; returns registered_tests if successful, or
// aborts the program otherwise.
// aborts the program otherwise.
...
@@ -45,6 +53,10 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
...
@@ -45,6 +53,10 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
typedef
::
std
::
set
<
const
char
*>::
const_iterator
DefinedTestIter
;
typedef
::
std
::
set
<
const
char
*>::
const_iterator
DefinedTestIter
;
registered_
=
true
;
registered_
=
true
;
// Skip initial whitespace in registered_tests since some
// preprocessors prefix stringizied literals with whitespace.
registered_tests
=
SkipSpaces
(
registered_tests
);
Message
errors
;
Message
errors
;
::
std
::
set
<
String
>
tests
;
::
std
::
set
<
String
>
tests
;
for
(
const
char
*
names
=
registered_tests
;
names
!=
NULL
;
for
(
const
char
*
names
=
registered_tests
;
names
!=
NULL
;
...
...
test/gtest-filepath_test.cc
View file @
cfcbc298
...
@@ -153,31 +153,31 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
...
@@ -153,31 +153,31 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
#if GTEST_HAS_ALT_PATH_SEP_
#if GTEST_HAS_ALT_PATH_SEP_
// Test RemoveDirectory* functions with "/".
// Tests that RemoveDirectoryName() works with the alternate separator
// on Windows.
// RemoveDirectoryName
"/afile"
-> "afile"
// RemoveDirectoryName
("/afile")
-> "afile"
TEST
(
RemoveDirectoryNameTest
,
RootFileShouldGiveFileNameForAlternateSeparator
)
{
TEST
(
RemoveDirectoryNameTest
,
RootFileShouldGiveFileNameForAlternateSeparator
)
{
EXPECT_STREQ
(
"afile"
,
EXPECT_STREQ
(
"afile"
,
FilePath
(
"/afile"
).
RemoveDirectoryName
().
c_str
());
FilePath
(
"/afile"
).
RemoveDirectoryName
().
c_str
());
}
}
// RemoveDirectoryName
"adir/"
-> ""
// RemoveDirectoryName
("adir/")
-> ""
TEST
(
RemoveDirectoryNameTest
,
WhereThereIsNoFileNameForAlternateSeparator
)
{
TEST
(
RemoveDirectoryNameTest
,
WhereThereIsNoFileNameForAlternateSeparator
)
{
EXPECT_STREQ
(
""
,
EXPECT_STREQ
(
""
,
FilePath
(
"adir/"
).
RemoveDirectoryName
().
c_str
());
FilePath
(
"adir/"
).
RemoveDirectoryName
().
c_str
());
}
}
// RemoveDirectoryName
"adir/afile"
-> "afile"
// RemoveDirectoryName
("adir/afile")
-> "afile"
TEST
(
RemoveDirectoryNameTest
,
ShouldGiveFileNameForAlternateSeparator
)
{
TEST
(
RemoveDirectoryNameTest
,
ShouldGiveFileNameForAlternateSeparator
)
{
EXPECT_STREQ
(
"afile"
,
EXPECT_STREQ
(
"afile"
,
FilePath
(
"adir/afile"
).
RemoveDirectoryName
().
c_str
());
FilePath
(
"adir/afile"
).
RemoveDirectoryName
().
c_str
());
}
}
// RemoveDirectoryName
"adir/subdir/afile"
-> "afile"
// RemoveDirectoryName
("adir/subdir/afile")
-> "afile"
TEST
(
RemoveDirectoryNameTest
,
ShouldAlsoGiveFileNameForAlternateSeparator
)
{
TEST
(
RemoveDirectoryNameTest
,
ShouldAlsoGiveFileNameForAlternateSeparator
)
{
EXPECT_STREQ
(
"afile"
,
EXPECT_STREQ
(
"afile"
,
FilePath
(
"adir/subdir/afile"
)
FilePath
(
"adir/subdir/afile"
).
RemoveDirectoryName
().
c_str
());
.
RemoveDirectoryName
().
c_str
());
}
}
#endif
#endif
...
@@ -222,32 +222,31 @@ TEST(RemoveFileNameTest, GivesRootDir) {
...
@@ -222,32 +222,31 @@ TEST(RemoveFileNameTest, GivesRootDir) {
#if GTEST_HAS_ALT_PATH_SEP_
#if GTEST_HAS_ALT_PATH_SEP_
// Test RemoveFile* functions with "/".
// Tests that RemoveFileName() works with the alternate separator on
// Windows.
// RemoveFileName
"adir/"
-> "adir/"
// RemoveFileName
("adir/")
-> "adir/"
TEST
(
RemoveFileNameTest
,
ButNoFileForAlternateSeparator
)
{
TEST
(
RemoveFileNameTest
,
ButNoFileForAlternateSeparator
)
{
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
,
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
,
FilePath
(
"adir/"
).
RemoveFileName
().
c_str
());
FilePath
(
"adir/"
).
RemoveFileName
().
c_str
());
}
}
// RemoveFileName
"adir/afile"
-> "adir/"
// RemoveFileName
("adir/afile")
-> "adir/"
TEST
(
RemoveFileNameTest
,
GivesDirNameForAlternateSeparator
)
{
TEST
(
RemoveFileNameTest
,
GivesDirNameForAlternateSeparator
)
{
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
,
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
,
FilePath
(
"adir/afile"
)
FilePath
(
"adir/afile"
).
RemoveFileName
().
c_str
());
.
RemoveFileName
().
c_str
());
}
}
// RemoveFileName
"adir/subdir/afile"
-> "adir/subdir/"
// RemoveFileName
("adir/subdir/afile")
-> "adir/subdir/"
TEST
(
RemoveFileNameTest
,
GivesDirAndSubDirNameForAlternateSeparator
)
{
TEST
(
RemoveFileNameTest
,
GivesDirAndSubDirNameForAlternateSeparator
)
{
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
"subdir"
GTEST_PATH_SEP_
,
EXPECT_STREQ
(
"adir"
GTEST_PATH_SEP_
"subdir"
GTEST_PATH_SEP_
,
FilePath
(
"adir/subdir/afile"
)
FilePath
(
"adir/subdir/afile"
).
RemoveFileName
().
c_str
());
.
RemoveFileName
().
c_str
());
}
}
// RemoveFileName
"/afile"
-> "\"
// RemoveFileName
("/afile")
-> "\"
TEST
(
RemoveFileNameTest
,
GivesRootDirForAlternateSeparator
)
{
TEST
(
RemoveFileNameTest
,
GivesRootDirForAlternateSeparator
)
{
EXPECT_STREQ
(
GTEST_PATH_SEP_
,
EXPECT_STREQ
(
GTEST_PATH_SEP_
,
FilePath
(
"/afile"
).
RemoveFileName
().
c_str
());
FilePath
(
"/afile"
).
RemoveFileName
().
c_str
());
}
}
#endif
#endif
...
@@ -357,9 +356,8 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
...
@@ -357,9 +356,8 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
"foo"
,
"foo"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
).
RemoveTrailingPathSeparator
().
c_str
());
FilePath
(
"foo"
GTEST_PATH_SEP_
).
RemoveTrailingPathSeparator
().
c_str
());
#if GTEST_HAS_ALT_PATH_SEP_
#if GTEST_HAS_ALT_PATH_SEP_
EXPECT_STREQ
(
EXPECT_STREQ
(
"foo"
,
"foo"
,
FilePath
(
"foo/"
).
RemoveTrailingPathSeparator
().
c_str
());
FilePath
(
"foo/"
).
RemoveTrailingPathSeparator
().
c_str
());
#endif
#endif
}
}
...
@@ -465,7 +463,9 @@ TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
...
@@ -465,7 +463,9 @@ TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
#if GTEST_HAS_ALT_PATH_SEP_
#if GTEST_HAS_ALT_PATH_SEP_
// "foo\" =="foo/\" == "foo\\/"
// Tests that separators at the end of the string are normalized
// regardless of their combination (e.g. "foo\" =="foo/\" ==
// "foo\\/").
TEST
(
NormalizeTest
,
MixAlternateSeparatorAtStringEnd
)
{
TEST
(
NormalizeTest
,
MixAlternateSeparatorAtStringEnd
)
{
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
,
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
,
FilePath
(
"foo/"
).
c_str
());
FilePath
(
"foo/"
).
c_str
());
...
@@ -678,6 +678,7 @@ TEST(FilePathTest, IsRootDirectory) {
...
@@ -678,6 +678,7 @@ TEST(FilePathTest, IsRootDirectory) {
EXPECT_FALSE
(
FilePath
(
"c|/"
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
"c|/"
).
IsRootDirectory
());
#else
#else
EXPECT_TRUE
(
FilePath
(
"/"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"/"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"//"
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
""
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
""
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
"
\\
"
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
"
\\
"
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
"/x"
).
IsRootDirectory
());
EXPECT_FALSE
(
FilePath
(
"/x"
).
IsRootDirectory
());
...
...
test/gtest_unittest.cc
View file @
cfcbc298
...
@@ -74,9 +74,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
...
@@ -74,9 +74,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <pthread.h>
#include <pthread.h>
#endif // GTEST_HAS_PTHREAD
#endif // GTEST_HAS_PTHREAD
#ifdef __BORLANDC__
#include <map>
#include <map>
#endif
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
...
@@ -1388,12 +1386,16 @@ TEST(StringTest, CanBeAssignedSelf) {
...
@@ -1388,12 +1386,16 @@ TEST(StringTest, CanBeAssignedSelf) {
EXPECT_STREQ
(
"hello"
,
dest
.
c_str
());
EXPECT_STREQ
(
"hello"
,
dest
.
c_str
());
}
}
// Sun Studio < 12 incorrectly rejects this code due to an overloading
// ambiguity.
#if !(defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
// Tests streaming a String.
// Tests streaming a String.
TEST
(
StringTest
,
Streams
)
{
TEST
(
StringTest
,
Streams
)
{
EXPECT_EQ
(
StreamableToString
(
String
()),
"(null)"
);
EXPECT_EQ
(
StreamableToString
(
String
()),
"(null)"
);
EXPECT_EQ
(
StreamableToString
(
String
(
""
)),
""
);
EXPECT_EQ
(
StreamableToString
(
String
(
""
)),
""
);
EXPECT_EQ
(
StreamableToString
(
String
(
"a
\0
b"
,
3
)),
"a
\\
0b"
);
EXPECT_EQ
(
StreamableToString
(
String
(
"a
\0
b"
,
3
)),
"a
\\
0b"
);
}
}
#endif
// Tests that String::Format() works.
// Tests that String::Format() works.
TEST
(
StringTest
,
FormatWorks
)
{
TEST
(
StringTest
,
FormatWorks
)
{
...
@@ -2050,7 +2052,7 @@ static void SetEnv(const char* name, const char* value) {
...
@@ -2050,7 +2052,7 @@ static void SetEnv(const char* name, const char* value) {
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
// Environment variables are not supported on Windows CE.
// Environment variables are not supported on Windows CE.
return
;
return
;
#elif defined(__BORLANDC__)
#elif defined(__BORLANDC__)
|| defined(__SunOS_5_8) || defined(__SunOS_5_9)
// C++Builder's putenv only stores a pointer to its parameter; we have to
// C++Builder's putenv only stores a pointer to its parameter; we have to
// ensure that the string remains valid as long as it might be needed.
// ensure that the string remains valid as long as it might be needed.
// We use an std::map to do so.
// We use an std::map to do so.
...
@@ -2063,7 +2065,11 @@ static void SetEnv(const char* name, const char* value) {
...
@@ -2063,7 +2065,11 @@ static void SetEnv(const char* name, const char* value) {
prev_env
=
added_env
[
name
];
prev_env
=
added_env
[
name
];
}
}
added_env
[
name
]
=
new
String
((
Message
()
<<
name
<<
"="
<<
value
).
GetString
());
added_env
[
name
]
=
new
String
((
Message
()
<<
name
<<
"="
<<
value
).
GetString
());
putenv
(
added_env
[
name
]
->
c_str
());
// The standard signature of putenv accepts a 'char*' argument. Other
// implementations, like C++Builder's, accept a 'const char*'.
// We cast away the 'const' since that would work for both variants.
putenv
(
const_cast
<
char
*>
(
added_env
[
name
]
->
c_str
()));
delete
prev_env
;
delete
prev_env
;
#elif GTEST_OS_WINDOWS // If we are on Windows proper.
#elif GTEST_OS_WINDOWS // If we are on Windows proper.
_putenv
((
Message
()
<<
name
<<
"="
<<
value
).
GetString
().
c_str
());
_putenv
((
Message
()
<<
name
<<
"="
<<
value
).
GetString
().
c_str
());
...
@@ -3013,7 +3019,10 @@ TEST_F(FloatTest, AlmostZeros) {
...
@@ -3013,7 +3019,10 @@ TEST_F(FloatTest, AlmostZeros) {
// In C++Builder, names within local classes (such as used by
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
// scoping class. Use a static local alias as a workaround.
static
const
FloatTest
::
TestValues
&
v
(
this
->
values_
);
// We use the assignment syntax since some compilers, like Sun Studio,
// don't allow initializing references using construction syntax
// (parentheses).
static
const
FloatTest
::
TestValues
&
v
=
this
->
values_
;
EXPECT_FLOAT_EQ
(
0.0
,
v
.
close_to_positive_zero
);
EXPECT_FLOAT_EQ
(
0.0
,
v
.
close_to_positive_zero
);
EXPECT_FLOAT_EQ
(
-
0.0
,
v
.
close_to_negative_zero
);
EXPECT_FLOAT_EQ
(
-
0.0
,
v
.
close_to_negative_zero
);
...
@@ -3065,7 +3074,10 @@ TEST_F(FloatTest, NaN) {
...
@@ -3065,7 +3074,10 @@ TEST_F(FloatTest, NaN) {
// In C++Builder, names within local classes (such as used by
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
// scoping class. Use a static local alias as a workaround.
static
const
FloatTest
::
TestValues
&
v
(
this
->
values_
);
// We use the assignment syntax since some compilers, like Sun Studio,
// don't allow initializing references using construction syntax
// (parentheses).
static
const
FloatTest
::
TestValues
&
v
=
this
->
values_
;
EXPECT_NONFATAL_FAILURE
(
EXPECT_FLOAT_EQ
(
v
.
nan1
,
v
.
nan1
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_FLOAT_EQ
(
v
.
nan1
,
v
.
nan1
),
"v.nan1"
);
"v.nan1"
);
...
@@ -3180,7 +3192,10 @@ TEST_F(DoubleTest, AlmostZeros) {
...
@@ -3180,7 +3192,10 @@ TEST_F(DoubleTest, AlmostZeros) {
// In C++Builder, names within local classes (such as used by
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
// scoping class. Use a static local alias as a workaround.
static
const
DoubleTest
::
TestValues
&
v
(
this
->
values_
);
// We use the assignment syntax since some compilers, like Sun Studio,
// don't allow initializing references using construction syntax
// (parentheses).
static
const
DoubleTest
::
TestValues
&
v
=
this
->
values_
;
EXPECT_DOUBLE_EQ
(
0.0
,
v
.
close_to_positive_zero
);
EXPECT_DOUBLE_EQ
(
0.0
,
v
.
close_to_positive_zero
);
EXPECT_DOUBLE_EQ
(
-
0.0
,
v
.
close_to_negative_zero
);
EXPECT_DOUBLE_EQ
(
-
0.0
,
v
.
close_to_negative_zero
);
...
@@ -3230,7 +3245,10 @@ TEST_F(DoubleTest, NaN) {
...
@@ -3230,7 +3245,10 @@ TEST_F(DoubleTest, NaN) {
// In C++Builder, names within local classes (such as used by
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
// scoping class. Use a static local alias as a workaround.
static
const
DoubleTest
::
TestValues
&
v
(
this
->
values_
);
// We use the assignment syntax since some compilers, like Sun Studio,
// don't allow initializing references using construction syntax
// (parentheses).
static
const
DoubleTest
::
TestValues
&
v
=
this
->
values_
;
// Nokia's STLport crashes if we try to output infinity or NaN.
// Nokia's STLport crashes if we try to output infinity or NaN.
EXPECT_NONFATAL_FAILURE
(
EXPECT_DOUBLE_EQ
(
v
.
nan1
,
v
.
nan1
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_DOUBLE_EQ
(
v
.
nan1
,
v
.
nan1
),
...
@@ -4015,7 +4033,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
...
@@ -4015,7 +4033,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
// The version of gcc used in XCode 2.2 has a bug and doesn't allow
// 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
// anonymous enums in assertions. Therefore the following test is not
// done on Mac.
// done on Mac.
#if !GTEST_OS_MAC
// Sun Studio also rejects this code.
#if !GTEST_OS_MAC && !defined(__SUNPRO_CC)
// Tests using assertions with anonymous enums.
// Tests using assertions with anonymous enums.
enum
{
enum
{
...
@@ -4060,7 +4079,7 @@ TEST(AssertionTest, AnonymousEnum) {
...
@@ -4060,7 +4079,7 @@ TEST(AssertionTest, AnonymousEnum) {
"Value of: CASE_B"
);
"Value of: CASE_B"
);
}
}
#endif // !GTEST_OS_MAC
#endif // !GTEST_OS_MAC
&& !defined(__SUNPRO_CC)
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment