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
ea9c49b9
Commit
ea9c49b9
authored
Apr 11, 2019
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2229 from return:haiku-support
PiperOrigin-RevId: 243104604
parents
520a1e52
0a00ba64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
28 deletions
+32
-28
primer.md
googletest/docs/primer.md
+20
-20
gtest-port-arch.h
googletest/include/gtest/internal/gtest-port-arch.h
+2
-0
gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+10
-8
No files found.
googletest/docs/primer.md
View file @
ea9c49b9
...
@@ -18,7 +18,7 @@ So what makes a good test, and how does googletest fit in? We believe:
...
@@ -18,7 +18,7 @@ So what makes a good test, and how does googletest fit in? We believe:
tests by running each of them on a different object. When a test fails,
tests by running each of them on a different object. When a test fails,
googletest allows you to run it in isolation for quick debugging.
googletest allows you to run it in isolation for quick debugging.
1.
Tests should be well
*organized*
and reflect the structure of the tested
1.
Tests should be well
*organized*
and reflect the structure of the tested
code. googletest groups related tests into test
suit
es that can share data
code. googletest groups related tests into test
cas
es that can share data
and subroutines. This common pattern is easy to recognize and makes tests
and subroutines. This common pattern is easy to recognize and makes tests
easy to maintain. Such consistency is especially helpful when people switch
easy to maintain. Such consistency is especially helpful when people switch
projects and start to work on a new code base.
projects and start to work on a new code base.
...
@@ -65,7 +65,7 @@ The term _Test_ is commonly of broad enough sense, including ISTQB's definition
...
@@ -65,7 +65,7 @@ The term _Test_ is commonly of broad enough sense, including ISTQB's definition
of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as
of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as
was used in Google Test is of contradictory sense and thus confusing.
was used in Google Test is of contradictory sense and thus confusing.
googletest recently started replacing the term _Test Case_ by _Test Suite_
.
The
googletest recently started replacing the term _Test Case_ by _Test Suite_ The
preferred API is TestSuite
*. The older TestCase*
API is being slowly deprecated
preferred API is TestSuite
*. The older TestCase*
API is being slowly deprecated
and refactored away
and refactored away
...
@@ -85,15 +85,15 @@ current function; otherwise the program continues normally.
...
@@ -85,15 +85,15 @@ current function; otherwise the program continues normally.
*Tests*
use assertions to verify the tested code's behavior. If a test crashes
*Tests*
use assertions to verify the tested code's behavior. If a test crashes
or has a failed assertion, then it
*fails*
; otherwise it
*succeeds*
.
or has a failed assertion, then it
*fails*
; otherwise it
*succeeds*
.
A
*test
suit
e*
contains one or many tests. You should group your tests into test
A
*test
cas
e*
contains one or many tests. You should group your tests into test
suit
es that reflect the structure of the tested code. When multiple tests in a
cas
es that reflect the structure of the tested code. When multiple tests in a
test
suit
e need to share common objects and subroutines, you can put them into a
test
cas
e need to share common objects and subroutines, you can put them into a
*test fixture*
class.
*test fixture*
class.
A
*test program*
can contain multiple test
suit
es.
A
*test program*
can contain multiple test
cas
es.
We'll now explain how to write a test program, starting at the individual
We'll now explain how to write a test program, starting at the individual
assertion level and building up to tests and test
suit
es.
assertion level and building up to tests and test
cas
es.
## Assertions
## Assertions
...
@@ -256,10 +256,10 @@ TEST(TestSuiteName, TestName) {
...
@@ -256,10 +256,10 @@ TEST(TestSuiteName, TestName) {
```
```
`TEST()`
arguments go from general to specific. The
*first*
argument is the name
`TEST()`
arguments go from general to specific. The
*first*
argument is the name
of the test
suit
e, and the
*second*
argument is the test's name within the test
of the test
cas
e, and the
*second*
argument is the test's name within the test
suit
e. Both names must be valid C++ identifiers, and they should not contain
cas
e. Both names must be valid C++ identifiers, and they should not contain
underscore (
`_`
). A test's
*full name*
consists of its containing test
suit
e and
underscore (
`_`
). A test's
*full name*
consists of its containing test
cas
e and
its individual name. Tests from different test
suit
es can have the same
its individual name. Tests from different test
cas
es can have the same
individual name.
individual name.
For example, let's take a simple integer function:
For example, let's take a simple integer function:
...
@@ -268,7 +268,7 @@ For example, let's take a simple integer function:
...
@@ -268,7 +268,7 @@ For example, let's take a simple integer function:
int
Factorial
(
int
n
);
// Returns the factorial of n
int
Factorial
(
int
n
);
// Returns the factorial of n
```
```
A test
suit
e for this function might look like:
A test
cas
e for this function might look like:
```
c++
```
c++
// Tests factorial of 0.
// Tests factorial of 0.
...
@@ -285,13 +285,13 @@ TEST(FactorialTest, HandlesPositiveInput) {
...
@@ -285,13 +285,13 @@ TEST(FactorialTest, HandlesPositiveInput) {
}
}
```
```
googletest groups the test results by test
suit
es, so logically-related tests
googletest groups the test results by test
cas
es, so logically-related tests
should be in the same test
suit
e; in other words, the first argument to their
should be in the same test
cas
e; in other words, the first argument to their
`TEST()`
should be the same. In the above example, we have two tests,
`TEST()`
should be the same. In the above example, we have two tests,
`HandlesZeroInput`
and
`HandlesPositiveInput`
, that belong to the same test
suit
e
`HandlesZeroInput`
and
`HandlesPositiveInput`
, that belong to the same test
cas
e
`FactorialTest`
.
`FactorialTest`
.
When naming your test
suit
es and tests, you should follow the same convention as
When naming your test
cas
es and tests, you should follow the same convention as
for
[
naming functions and
for
[
naming functions and
classes](https://google.github.io/styleguide/cppguide.html#Function_Names).
classes](https://google.github.io/styleguide/cppguide.html#Function_Names).
...
@@ -327,7 +327,7 @@ TEST_F(TestSuiteName, TestName) {
...
@@ -327,7 +327,7 @@ TEST_F(TestSuiteName, TestName) {
}
}
```
```
Like
`TEST()`
, the first argument is the test
suit
e name, but for
`TEST_F()`
this
Like
`TEST()`
, the first argument is the test
cas
e name, but for
`TEST_F()`
this
must be the name of the test fixture class. You've probably guessed:
`_F`
is for
must be the name of the test fixture class. You've probably guessed:
`_F`
is for
fixture.
fixture.
...
@@ -342,7 +342,7 @@ declaration`".
...
@@ -342,7 +342,7 @@ declaration`".
For each test defined with
`TEST_F()`
, googletest will create a
*fresh*
test
For each test defined with
`TEST_F()`
, googletest will create a
*fresh*
test
fixture at runtime, immediately initialize it via
`SetUp()`
, run the test,
fixture at runtime, immediately initialize it via
`SetUp()`
, run the test,
clean up by calling
`TearDown()`
, and then delete the test fixture. Note that
clean up by calling
`TearDown()`
, and then delete the test fixture. Note that
different tests in the same test
suit
e have different test fixture objects, and
different tests in the same test
cas
e have different test fixture objects, and
googletest always deletes a test fixture before it creates the next one.
googletest always deletes a test fixture before it creates the next one.
googletest does
**not**
reuse the same test fixture for multiple tests. Any
googletest does
**not**
reuse the same test fixture for multiple tests. Any
changes one test makes to the fixture do not affect other tests.
changes one test makes to the fixture do not affect other tests.
...
@@ -439,7 +439,7 @@ your defined tests in order to run them.
...
@@ -439,7 +439,7 @@ your defined tests in order to run them.
After defining your tests, you can run them with
`RUN_ALL_TESTS()`
, which
After defining your tests, you can run them with
`RUN_ALL_TESTS()`
, which
returns
`0`
if all the tests are successful, or
`1`
otherwise. Note that
returns
`0`
if all the tests are successful, or
`1`
otherwise. Note that
`RUN_ALL_TESTS()`
runs
*all tests*
in your link unit -- they can be from
`RUN_ALL_TESTS()`
runs
*all tests*
in your link unit -- they can be from
different test
suit
es, or even different source files.
different test
cas
es, or even different source files.
When invoked, the
`RUN_ALL_TESTS()`
macro:
When invoked, the
`RUN_ALL_TESTS()`
macro:
...
@@ -511,7 +511,7 @@ class FooTest : public ::testing::Test {
...
@@ -511,7 +511,7 @@ class FooTest : public ::testing::Test {
// before the destructor).
// before the destructor).
}
}
// Objects declared here can be used by all tests in the test
suit
e for Foo.
// Objects declared here can be used by all tests in the test
cas
e for Foo.
};
};
// Tests that the Foo::Bar() method does Abc.
// Tests that the Foo::Bar() method does Abc.
...
...
googletest/include/gtest/internal/gtest-port-arch.h
View file @
ea9c49b9
...
@@ -100,6 +100,8 @@
...
@@ -100,6 +100,8 @@
# define GTEST_OS_OPENBSD 1
# define GTEST_OS_OPENBSD 1
#elif defined __QNX__
#elif defined __QNX__
# define GTEST_OS_QNX 1
# define GTEST_OS_QNX 1
#elif defined(__HAIKU__)
#define GTEST_OS_HAIKU 1
#endif // __CYGWIN__
#endif // __CYGWIN__
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
googletest/include/gtest/internal/gtest-port.h
View file @
ea9c49b9
...
@@ -115,6 +115,7 @@
...
@@ -115,6 +115,7 @@
// GTEST_OS_CYGWIN - Cygwin
// GTEST_OS_CYGWIN - Cygwin
// GTEST_OS_DRAGONFLY - DragonFlyBSD
// GTEST_OS_DRAGONFLY - DragonFlyBSD
// GTEST_OS_FREEBSD - FreeBSD
// GTEST_OS_FREEBSD - FreeBSD
// GTEST_OS_HAIKU - Haiku
// GTEST_OS_FUCHSIA - Fuchsia
// GTEST_OS_FUCHSIA - Fuchsia
// GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
// GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
// GTEST_OS_HPUX - HP-UX
// GTEST_OS_HPUX - HP-UX
...
@@ -458,8 +459,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -458,8 +459,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// Cygwin 1.7 and below doesn't support ::std::wstring.
// Cygwin 1.7 and below doesn't support ::std::wstring.
// Solaris' libc++ doesn't support it either. Android has
// Solaris' libc++ doesn't support it either. Android has
// no support for it at least as recent as Froyo (2.2).
// no support for it at least as recent as Froyo (2.2).
# define GTEST_HAS_STD_WSTRING \
#define GTEST_HAS_STD_WSTRING \
(!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
(!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
GTEST_OS_HAIKU))
#endif // GTEST_HAS_STD_WSTRING
#endif // GTEST_HAS_STD_WSTRING
...
@@ -536,7 +538,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -536,7 +538,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#define GTEST_HAS_PTHREAD \
#define GTEST_HAS_PTHREAD \
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD)
GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \
GTEST_OS_HAIKU)
#endif // GTEST_HAS_PTHREAD
#endif // GTEST_HAS_PTHREAD
#if GTEST_HAS_PTHREAD
#if GTEST_HAS_PTHREAD
...
@@ -592,11 +595,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -592,11 +595,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// 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_CYGWIN || GTEST_OS_SOLARIS || \
#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW || \
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || GTEST_OS_DRAGONFLY || \
GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU)
GTEST_OS_GNU_KFREEBSD)
# define GTEST_HAS_DEATH_TEST 1
# define GTEST_HAS_DEATH_TEST 1
#endif
#endif
...
...
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