2023-08-08 06:17:32 +00:00
|
|
|
# Googletest Samples
|
Import GoogleTest 1.8.1 into the vendor tree under `^/google/googletest/dist`
GoogleTest is a widely used opensource C++ test framework, licensed under a
BSD 3-clause license. It fits best in the realm of doing functional/whitebox
testing, similar to ATF's C++ library. However, it has additional functionality
such as per-testcase setup fixtures, class level setup and teardown fixtures,
and a lot more functional/syntactic goodness.
In addition to large corporations adopting GoogleTest as their defacto C++ test
library (Facebook, Google, etc), many opensource projects have adopted
GoogleTest, e.g., the Capsicum project, Chrome, etc.
The goal for importing this is to enable testing with zfsd and integrate
googletest into kyua.
This is the final version that will support a pre-C++-11 compiler. As such, this
test framework will not be available to gcc 4.2.1, similar to ATF's C++ library.
A subsequent set of commits will:
1. Tag ^/google/googletest/dist as ^/google/googletest/1.8.1 using `svn cp ^/google/googletest/dist ^/google/googletest/1.8.1`.
2. Import this code into ^/head and integrate it into the build for all applicable
platforms and C++ compile toolchains.
The import was done via the following command pipeline on OSX:
```
curl -L https://github.com/google/googletest/archive/release-1.8.1.tar.gz | tar --strip-components=1 -xvzf - -C dist/
```
Approved by: emaste (mentor)
Discussed with: brooks, jtl
Differential Revision: https://reviews.freebsd.org/D18622
2019-02-13 02:16:52 +00:00
|
|
|
|
2023-08-08 06:17:32 +00:00
|
|
|
If you're like us, you'd like to look at
|
|
|
|
[googletest samples.](https://github.com/google/googletest/blob/main/googletest/samples)
|
Import GoogleTest 1.8.1 into the vendor tree under `^/google/googletest/dist`
GoogleTest is a widely used opensource C++ test framework, licensed under a
BSD 3-clause license. It fits best in the realm of doing functional/whitebox
testing, similar to ATF's C++ library. However, it has additional functionality
such as per-testcase setup fixtures, class level setup and teardown fixtures,
and a lot more functional/syntactic goodness.
In addition to large corporations adopting GoogleTest as their defacto C++ test
library (Facebook, Google, etc), many opensource projects have adopted
GoogleTest, e.g., the Capsicum project, Chrome, etc.
The goal for importing this is to enable testing with zfsd and integrate
googletest into kyua.
This is the final version that will support a pre-C++-11 compiler. As such, this
test framework will not be available to gcc 4.2.1, similar to ATF's C++ library.
A subsequent set of commits will:
1. Tag ^/google/googletest/dist as ^/google/googletest/1.8.1 using `svn cp ^/google/googletest/dist ^/google/googletest/1.8.1`.
2. Import this code into ^/head and integrate it into the build for all applicable
platforms and C++ compile toolchains.
The import was done via the following command pipeline on OSX:
```
curl -L https://github.com/google/googletest/archive/release-1.8.1.tar.gz | tar --strip-components=1 -xvzf - -C dist/
```
Approved by: emaste (mentor)
Discussed with: brooks, jtl
Differential Revision: https://reviews.freebsd.org/D18622
2019-02-13 02:16:52 +00:00
|
|
|
The sample directory has a number of well-commented samples showing how to use a
|
|
|
|
variety of googletest features.
|
|
|
|
|
|
|
|
* Sample #1 shows the basic steps of using googletest to test C++ functions.
|
|
|
|
* Sample #2 shows a more complex unit test for a class with multiple member
|
|
|
|
functions.
|
|
|
|
* Sample #3 uses a test fixture.
|
|
|
|
* Sample #4 teaches you how to use googletest and `googletest.h` together to
|
|
|
|
get the best of both libraries.
|
|
|
|
* Sample #5 puts shared testing logic in a base test fixture, and reuses it in
|
|
|
|
derived fixtures.
|
|
|
|
* Sample #6 demonstrates type-parameterized tests.
|
|
|
|
* Sample #7 teaches the basics of value-parameterized tests.
|
|
|
|
* Sample #8 shows using `Combine()` in value-parameterized tests.
|
|
|
|
* Sample #9 shows use of the listener API to modify Google Test's console
|
|
|
|
output and the use of its reflection API to inspect test results.
|
|
|
|
* Sample #10 shows use of the listener API to implement a primitive memory
|
|
|
|
leak checker.
|