Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docs Build

on:
push:
branches:
- devel

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
- run: yarn install --frozen-lockfile

- name: Build
run: yarn docs:build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/.vitepress/dist
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ msvc-sln*
# Currently we use Doxygen for dep graphs and the full docs are only slowly
# being filled in, so we definitely do not want git to deal with the docs.
docs/doxygen

# vitepress
docs/.vitepress/dist/
node_modules
yarn-error.log


*.cache
compile_commands.json
582 changes: 582 additions & 0 deletions docs-others/command-line.md

Large diffs are not rendered by default.

1,517 changes: 1,517 additions & 0 deletions docs-others/release-notes.md

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { defineConfig } from 'vitepress'

export default defineConfig({
lang: 'en-US',
title: 'Catch2',
titleTemplate: 'Catch2', // otherwise false
description: 'Catch2, c++ / cpp unit test open source project.',
appearance: true, // dark mode enabled
base: '/Catch2/',
lastUpdated: true,
// markdown
// https://vitepress.vuejs.org/config/app-configs.html#markdown
markdown: {
theme: 'material-palenight',
lineNumbers: true
},

themeConfig: {
nav: [
{ text: 'Contribute', link: 'https://github.com/catchorg/Catch2'}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/catchorg/Catch2' },
//{ icon: 'linkedin', link: 'https://www.linkedin.com/in/ryankert01/'}
],
sidebar: [
{
text: 'Guide',
items: [
{ text: 'Introduction', link: '/intro' },
{ text: 'Getting Started', link: '/tutorial' }
]
},
{
text: 'Writing tests',
items: [
{ text: 'Assertion macros', link: '/assertions' },
{ text: 'Matchers', link: '/matchers' },
{ text: 'Logging macros', link: '/logging' },
{ text: 'Test cases and sections', link: '/test-cases-and-sections' },
{ text: 'Test fixtures', link: '/test-fixtures' },
{ text: 'Reporters', link: '/reporters' },
{ text: 'Event Listeners', link: '/event-listeners' },
{ text: 'Data Generators', link: '/generators' },
{ text: 'Other macros', link: '/other-macros' },
{ text: 'Micro benchmarking', link: '/benchmarks' }
]
},
{
text: 'Fine tuning',
items: [
{ text: 'Supplying your own main()', link: '/own-main' },
{ text: 'Compile-time configuration', link: '/configuration' },
{ text: 'String Conversions', link: '/tostring' },
]
},
{
text: 'Running Command Line',
items: [
{ text: 'Command Line', link: '/command-line' },
]
},
{
text: 'Odds and ends',
items: [
{ text: 'Frequently Asked Questions (FAQ)', link: '/faq' },
{ text: 'Best practices and other tips', link: '/usage-tips' },
{ text: 'CMake integration', link: '/cmake-integration' },
{ text: 'CI and other miscellaneous pieces', link: '/ci-and-misc' },
{ text: 'Known limitations', link: '/limitations' }

]
},
{
text: 'Other',
items: [
{ text: 'Why Catch2?', link: '/why-catch.md' },
{ text: 'Migrating from v2 to v3', link: '/migrate-v2-to-v3' },
{ text: 'Open Source Projects using Catch2', link: '/opensource-users' },
{ text: 'Commercial Projects using Catch2', link: '/commercial-users' },
{ text: 'Contributing', link: '/contributing' },
{ text: 'Release Notes', link: '/release-notes' },
{ text: 'Deprecations and incoming changes', link: '/deprecations' },
]
},
]
}
});

File renamed without changes.
7 changes: 1 addition & 6 deletions docs/assertions.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<a id="top"></a>
# Assertion Macros

**Contents**<br>
[Natural Expressions](#natural-expressions)<br>
[Exceptions](#exceptions)<br>
[Matcher expressions](#matcher-expressions)<br>
[Thread Safety](#thread-safety)<br>
[Expressions with commas](#expressions-with-commas)<br>


Most test frameworks have a large collection of assertion macros to capture all possible conditional forms (```_EQUALS```, ```_NOTEQUALS```, ```_GREATER_THAN``` etc).

Expand Down
16 changes: 8 additions & 8 deletions docs/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ Benchmarks can be specified anywhere inside a Catch test case.
There is a simple and a slightly more advanced version of the `BENCHMARK` macro.

Let's have a look how a naive Fibonacci implementation could be benchmarked:
```c++
```cpp
std::uint64_t Fibonacci(std::uint64_t number) {
return number < 2 ? 1 : Fibonacci(number - 1) + Fibonacci(number - 2);
}
```
Now the most straight forward way to benchmark this function, is just adding a `BENCHMARK` macro to our test case:
```c++
```cpp
TEST_CASE("Fibonacci") {
CHECK(Fibonacci(0) == 1);
// some more asserts..
Expand Down Expand Up @@ -121,7 +121,7 @@ the macro, some advanced features are available. The contents of the simple benc
while the blocks of the advanced benchmarks are invoked exactly twice:
once during the estimation phase, and another time during the execution phase.

```c++
```cpp
BENCHMARK("simple"){ return long_computation(); };

BENCHMARK_ADVANCED("advanced")(Catch::Benchmark::Chronometer meter) {
Expand All @@ -145,7 +145,7 @@ that needs to be done outside the measurement can be done outside the call to
The callable object passed in to `measure` can optionally accept an `int`
parameter.

```c++
```cpp
meter.measure([](int i) { return long_computation(i); });
```

Expand All @@ -155,7 +155,7 @@ for example. The number of runs can be known beforehand by calling
`Catch::Benchmark::Chronometer::runs`; with this one can set up a different instance to be
mutated by each run.

```c++
```cpp
std::vector<std::string> v(meter.runs());
std::fill(v.begin(), v.end(), test_string());
meter.measure([&v](int i) { in_place_escape(v[i]); });
Expand All @@ -168,7 +168,7 @@ the resetting code.
It is also possible to just provide an argument name to the simple `BENCHMARK` macro to get
the same semantics as providing a callable to `meter.measure` with `int` argument:

```c++
```cpp
BENCHMARK("indexed", i){ return long_computation(i); };
```

Expand All @@ -185,7 +185,7 @@ To solve this conundrum, Catch provides class templates that let you manually
construct and destroy objects without dynamic allocation and in a way that lets
you measure construction and destruction separately.

```c++
```cpp
BENCHMARK_ADVANCED("construct")(Catch::Benchmark::Chronometer meter) {
std::vector<Catch::Benchmark::storage_for<std::string>> storage(meter.runs());
meter.measure([&](int i) { storage[i].construct("thing"); });
Expand Down Expand Up @@ -231,7 +231,7 @@ That helps with keeping the code in a natural fashion.

Here's an example:

```c++
```cpp
// may measure nothing at all by skipping the long calculation since its
// result is not used
BENCHMARK("no return"){ long_calculation(); };
Expand Down
20 changes: 9 additions & 11 deletions docs/cmake-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you need custom `main`, you should link only against `Catch2::Catch2`.

This means that if Catch2 has been installed on the system, it should
be enough to do
```cmake
```bash
find_package(Catch2 3 REQUIRED)
# These tests can use the Catch2-provided main
add_executable(tests test.cpp)
Expand All @@ -45,7 +45,7 @@ above still works.


Another possibility is to use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html):
```cmake
```bash
Include(FetchContent)

FetchContent_Declare(
Expand Down Expand Up @@ -84,7 +84,7 @@ a target. This function works by running the resulting executable with
existing tests.

#### Usage
```cmake
```bash
cmake_minimum_required(VERSION 3.5)

project(baz LANGUAGES CXX VERSION 0.0.1)
Expand All @@ -102,7 +102,7 @@ When using `FetchContent`, `include(Catch)` will fail unless
`CMAKE_MODULE_PATH` is explicitly updated to include the extras
directory.

```cmake
```bash
# ... FetchContent ...
#
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
Expand All @@ -113,7 +113,7 @@ catch_discover_tests()

#### Customization
`catch_discover_tests` can be given several extra argumets:
```cmake
```bash
catch_discover_tests(target
[TEST_SPEC arg1...]
[EXTRA_ARGS arg1...]
Expand Down Expand Up @@ -216,7 +216,7 @@ parsed are *silently ignored*.

#### Usage

```cmake
```bash
cmake_minimum_required(VERSION 3.5)

project(baz LANGUAGES CXX VERSION 0.0.1)
Expand Down Expand Up @@ -252,7 +252,7 @@ automatically discovered. Defaults to `OFF`.
Optionally, one can specify a launching command to run tests by setting the
variable `OptionalCatchTestLauncher` before calling `ParseAndAddCatchTests`. For
instance to run some tests using `MPI` and other sequentially, one can write
```cmake
```bash
set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC})
ParseAndAddCatchTests(mpi_foo)
unset(OptionalCatchTestLauncher)
Expand Down Expand Up @@ -370,7 +370,7 @@ If you cannot install Catch2 from a package manager (e.g. Ubuntu 16.04
provides catch only in version 1.2.0) you might want to install it from
the repository instead. Assuming you have enough rights, you can just
install it to the default location, like so:
```
```bash
$ git clone https://github.com/catchorg/Catch2.git
$ cd Catch2
$ cmake -Bbuild -H. -DBUILD_TESTING=OFF
Expand All @@ -386,7 +386,7 @@ accordingly.
## Installing Catch2 from vcpkg

Alternatively, you can build and install Catch2 using [vcpkg](https://github.com/microsoft/vcpkg/) dependency manager:
```
```bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
Expand All @@ -397,6 +397,4 @@ cd vcpkg
The catch2 port in vcpkg is kept up to date by microsoft team members and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.

---

[Home](Readme.md#top)
Loading