├── .clang-format ├── .github ├── dependabot.yml └── workflows │ ├── build-and-test-via-cmake.yml │ └── build-and-test-visual-studio-solutions.yml ├── .gitignore ├── CMakeLists.txt ├── README.md ├── code ├── CMakeLists.txt └── YourCodeGoesHere.h ├── create_visual_studio_project.bat ├── install.windows.ps1 ├── lib ├── ApprovalTests.hpp ├── ApprovalTests.v.10.13.0.hpp ├── CMakeLists.txt └── catch2v3 │ └── CMakeLists.txt ├── notes_on_cmake.txt └── tests ├── CMakeLists.txt ├── DemoTest.DemoCombinationTestCase.approved.txt ├── DemoTest.DemoSimpleTestCase.approved.txt ├── DemoTest.cpp ├── NewTest.ApprovingText.approved.txt ├── NewTest.ApprovingWithReporters.approved.txt ├── NewTest.cpp ├── Tutorial.cpp └── main.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AllowShortFunctionsOnASingleLine: None 5 | AlignAfterOpenBracket: Align 6 | AlwaysBreakAfterReturnType: None 7 | BinPackArguments: false 8 | BinPackParameters: false 9 | BreakBeforeBraces: Allman 10 | ColumnLimit: 80 11 | IndentWidth: 4 12 | FixNamespaceComments: false 13 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 14 | BreakConstructorInitializers: BeforeComma 15 | KeepEmptyLinesAtTheStartOfBlocks: true 16 | NamespaceIndentation: All 17 | PointerAlignment: Left 18 | ReflowComments: false 19 | SortIncludes: false 20 | SortUsingDeclarations: true 21 | SpaceAfterTemplateKeyword: true 22 | TabWidth: 4 23 | UseTab: Never 24 | ... 25 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | prefix: '. e ' 8 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test-via-cmake.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '3 14 1 * *' # - "Once a month" 8 | workflow_dispatch: 9 | 10 | jobs: 11 | clang-format: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: DoozyX/clang-format-lint-action@v0.17 16 | with: 17 | source: '.' 18 | exclude: './lib' 19 | clangFormatVersion: 9 20 | build: 21 | env: 22 | BUILD_PATH: ${{ github.workspace }}/${{ matrix.relative_build_dir_path }}build_space 23 | strategy: 24 | fail-fast: false 25 | matrix: 26 | include: 27 | - job-name: windows-latest 28 | os: windows-latest 29 | generator: '"Visual Studio 17 2022"' 30 | relative_build_dir_path: '' 31 | 32 | - job-name: windows-latest (clangcl) 33 | os: windows-latest 34 | generator: '"Visual Studio 17 2022" -T "clangcl"' 35 | relative_build_dir_path: '' 36 | 37 | - job-name: ubuntu-latest 38 | os: ubuntu-latest 39 | generator: '"Unix Makefiles"' 40 | relative_build_dir_path: '' 41 | 42 | - job-name: ubuntu-18.04-latest 43 | os: ubuntu-latest 44 | generator: '"Ninja"' 45 | relative_build_dir_path: '../' 46 | 47 | - job-name: macOS-latest 48 | os: macOS-latest 49 | generator: '"Unix Makefiles"' 50 | relative_build_dir_path: '' 51 | 52 | - job-name: macOS-latest-unity 53 | os: macOS-latest 54 | generator: '"Unix Makefiles" -DCMAKE_UNITY_BUILD=yes' 55 | relative_build_dir_path: '' 56 | 57 | - job-name: macOS-latest-ninja 58 | os: macOS-latest 59 | generator: '"Ninja"' 60 | relative_build_dir_path: '../' 61 | 62 | - job-name: macOS-latest-ninja-unity 63 | os: macOS-latest 64 | generator: '"Ninja" -DCMAKE_UNITY_BUILD=yes' 65 | relative_build_dir_path: '' 66 | runs-on: ${{ matrix.os }} 67 | name: ${{ matrix.job-name }} 68 | steps: 69 | - uses: actions/checkout@v4 70 | - uses: seanmiddleditch/gha-setup-ninja@v4 71 | if: contains(matrix.generator, 'Ninja') 72 | 73 | - name: configure 74 | run: | 75 | mkdir ${{ env.BUILD_PATH }} 76 | cd ${{ env.BUILD_PATH }} 77 | cmake --version 78 | cmake -G ${{ matrix.generator }} ${{ github.workspace }} -DCMAKE_BUILD_TYPE=Debug 79 | - name: build 80 | run: | 81 | cd ${{ env.BUILD_PATH }} 82 | cmake --build . --parallel 4 83 | - name: test 84 | run: | 85 | cd ${{ env.BUILD_PATH }} 86 | ctest --verbose --output-on-failure -C Debug 87 | 88 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test-visual-studio-solutions.yml: -------------------------------------------------------------------------------- 1 | name: build_vs 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | pull_request: 8 | branches: 9 | - '*' 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build_visual_studio_sln: 14 | runs-on: windows-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: create project 19 | run: | 20 | call create_visual_studio_project.bat 21 | shell: cmd 22 | 23 | - name: build 24 | run: | 25 | cd visual-studio 26 | cmake --build . 27 | shell: cmd 28 | 29 | - name: test 30 | run: | 31 | cd visual-studio 32 | ctest . -C debug 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # CMake 2 | cmake-build-*/ 3 | .vs/ 4 | *.received.* 5 | 6 | ## Ignore Visual Studio temporary files, build results, and 7 | ## files generated by popular Visual Studio add-ons. 8 | ## 9 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.userosscache 15 | *.sln.docstates 16 | 17 | # User-specific files (MonoDevelop/Xamarin Studio) 18 | *.userprefs 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | x64/ 26 | x86/ 27 | bld/ 28 | [Bb]in/ 29 | [Oo]bj/ 30 | [Ll]og/ 31 | 32 | # Visual Studio 2015/2017 cache/options directory 33 | .vs/ 34 | # Uncomment if you have tasks that create the project's static files in wwwroot 35 | #wwwroot/ 36 | 37 | # Visual Studio 2017 auto generated files 38 | Generated\ Files/ 39 | 40 | # MSTest test Results 41 | [Tt]est[Rr]esult*/ 42 | [Bb]uild[Ll]og.* 43 | 44 | # NUNIT 45 | *.VisualState.xml 46 | TestResult.xml 47 | 48 | # Build Results of an ATL Project 49 | [Dd]ebugPS/ 50 | [Rr]eleasePS/ 51 | dlldata.c 52 | 53 | # Benchmark Results 54 | BenchmarkDotNet.Artifacts/ 55 | 56 | # .NET Core 57 | project.lock.json 58 | project.fragment.lock.json 59 | artifacts/ 60 | **/Properties/launchSettings.json 61 | 62 | # StyleCop 63 | StyleCopReport.xml 64 | 65 | # Files built by Visual Studio 66 | *_i.c 67 | *_p.c 68 | *_i.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.pch 73 | *.pdb 74 | *.pgc 75 | *.pgd 76 | *.rsp 77 | *.sbr 78 | *.tlb 79 | *.tli 80 | *.tlh 81 | *.tmp 82 | *.tmp_proj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | 247 | # SQL Server files 248 | *.mdf 249 | *.ldf 250 | *.ndf 251 | 252 | # Business Intelligence projects 253 | *.rdl.data 254 | *.bim.layout 255 | *.bim_*.settings 256 | 257 | # Microsoft Fakes 258 | FakesAssemblies/ 259 | 260 | # GhostDoc plugin setting file 261 | *.GhostDoc.xml 262 | 263 | # Node.js Tools for Visual Studio 264 | .ntvs_analysis.dat 265 | node_modules/ 266 | 267 | # Visual Studio 6 build log 268 | *.plg 269 | 270 | # Visual Studio 6 workspace options file 271 | *.opt 272 | 273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 274 | *.vbw 275 | 276 | # Visual Studio LightSwitch build output 277 | **/*.HTMLClient/GeneratedArtifacts 278 | **/*.DesktopClient/GeneratedArtifacts 279 | **/*.DesktopClient/ModelManifest.xml 280 | **/*.Server/GeneratedArtifacts 281 | **/*.Server/ModelManifest.xml 282 | _Pvt_Extensions 283 | 284 | # Paket dependency manager 285 | .paket/paket.exe 286 | paket-files/ 287 | 288 | # FAKE - F# Make 289 | .fake/ 290 | 291 | # JetBrains Rider 292 | .idea/ 293 | *.sln.iml 294 | 295 | # CodeRush 296 | .cr/ 297 | 298 | # Python Tools for Visual Studio (PTVS) 299 | __pycache__/ 300 | *.pyc 301 | 302 | # Cake - Uncomment if you are using it 303 | # tools/** 304 | # !tools/packages.config 305 | 306 | # Tabs Studio 307 | *.tss 308 | 309 | # Telerik's JustMock configuration file 310 | *.jmconfig 311 | 312 | # BizTalk build output 313 | *.btp.cs 314 | *.btm.cs 315 | *.odx.cs 316 | *.xsd.cs 317 | 318 | # OpenCover UI analysis results 319 | OpenCover/ 320 | 321 | # Azure Stream Analytics local run output 322 | ASALocalRun/ 323 | 324 | # MSBuild Binary and Structured Log 325 | *.binlog 326 | 327 | .DS_Store 328 | .idea/ 329 | 330 | # machine generated folder 331 | visual-studio/ 332 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(ApprovalTests.cpp.StarterProject) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | set(CMAKE_VERBOSE_MAKEFILE off) 7 | 8 | enable_testing() 9 | add_subdirectory(code) 10 | add_subdirectory(lib) 11 | add_subdirectory(tests) 12 | 13 | 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ApprovalTests.cpp.StarterProject 2 | 3 | 4 | [![build](../../actions/workflows/build-and-test-via-cmake.yml/badge.svg)](../../actions/workflows/build-and-test-via-cmake.yml) 5 | [![Build Status](../../workflows/build_vs/badge.svg?branch=master)](../../actions?query=branch%3Amaster+workflow%3Abuild_vs) 6 | 7 | 8 | This is a starter project for: 9 | 10 | * ApprovalTests in C++ - see [ApprovalTests.cpp](https://github.com/approvals/ApprovalTests.cpp) 11 | * Catch2 test framework 12 | * CLion (and any other CMake-aware C++ build system) 13 | * Visual Studio 2017 (`visual-studio-2017\StarterProject.sln`) 14 | * Visual Studio 2019 (`visual-studio-2019\StarterProject2019.sln`) 15 | 16 | Works on Mac, Linux and Windows. 17 | 18 | Feel free to copy and go... 19 | 20 | ## Machine Setup (Windows) 21 | 22 | You can set up a machine from scratch by running the [PowerShell script: install.windows.ps1](install.windows.ps1). See the comments inside it for how to run it. 23 | 24 | If you already have a Windows environment, but just not C++ tools, you can run the second half of that script. 25 | 26 | ## Starting Point 27 | 28 | The tests in [NewTest](https://github.com/approvals/ApprovalTests.cpp.StarterProject/blob/master/tests/NewTest.cpp) should pass, and then you should delete/modify as needed to get started. 29 | 30 | 31 | Notes: 32 | 33 | * For more information, see the [ApprovalTests.cpp User Guide](https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/README.md#top) 34 | * You will need a Diff tool. 35 | * Suggestions: 36 | * Mac: [DiffMerge](https://sourcegear.com/diffmerge/) 37 | * Windows: [WinMerge](winmerge.org/) 38 | * Linux: [meld](http://meldmerge.org/) 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CODE_LIB_NAME StarterProject.code) 2 | add_library(${CODE_LIB_NAME} INTERFACE) 3 | target_include_directories(${CODE_LIB_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -------------------------------------------------------------------------------- /code/YourCodeGoesHere.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by LLEWELLYN FALCO on 12/14/17. 3 | // 4 | 5 | #ifndef CATCHPLAYGROUND_YOURCODEGOESHERE_H 6 | #define CATCHPLAYGROUND_YOURCODEGOESHERE_H 7 | 8 | #endif //CATCHPLAYGROUND_YOURCODEGOESHERE_H 9 | -------------------------------------------------------------------------------- /create_visual_studio_project.bat: -------------------------------------------------------------------------------- 1 | rmdir /s /q visual-studio 2 | mkdir visual-studio 3 | cd visual-studio 4 | cmake .. 5 | cd .. 6 | -------------------------------------------------------------------------------- /install.windows.ps1: -------------------------------------------------------------------------------- 1 | # To run this script directly, run this in an elevated admin PowerShell prompt: 2 | # Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/approvals/ApprovalTests.cpp.StarterProject/master/install.windows.ps1 | Invoke-Expression 3 | 4 | # This script is intended to setup a dev machine from scratch. Very useful for setting up a EC2 instance for mobbing. 5 | # 6 | 7 | 8 | iwr -useb https://raw.githubusercontent.com/JayBazuzi/machine-setup/main/windows.ps1 | iex 9 | iwr -useb https://raw.githubusercontent.com/JayBazuzi/machine-setup/main/cplusplus-clion-and-visual-studio.ps1 | Invoke-Expression 10 | 11 | 12 | # Clone repo 13 | & "C:\Program Files\Git\cmd\git.exe" clone https://github.com/approvals/ApprovalTests.cpp.StarterProject.git C:\Code\ApprovalTests.cpp.StarterProject 14 | 15 | # Done 16 | cls 17 | echo "Done!" 18 | -------------------------------------------------------------------------------- /lib/ApprovalTests.hpp: -------------------------------------------------------------------------------- 1 | #include "ApprovalTests.v.10.13.0.hpp" 2 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT TARGET ApprovalTests) 2 | set(LIB_NAME ApprovalTests) 3 | add_library(${LIB_NAME} INTERFACE) 4 | target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 5 | add_library(${LIB_NAME}::${LIB_NAME} ALIAS ${LIB_NAME}) 6 | endif() 7 | 8 | add_subdirectory(catch2v3) 9 | -------------------------------------------------------------------------------- /lib/catch2v3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | message(STATUS "Add CPM.cmake") 2 | # download CPM.cmake 3 | file( 4 | DOWNLOAD 5 | https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.6/CPM.cmake 6 | ${CMAKE_BINARY_DIR}/cmake/CPM.cmake 7 | EXPECTED_HASH SHA256=11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07 8 | ) 9 | include(${CMAKE_BINARY_DIR}/cmake/CPM.cmake) 10 | 11 | message(STATUS "Fetching catch2") 12 | CPMAddPackage( 13 | NAME catch2 14 | GITHUB_REPOSITORY catchorg/Catch2 15 | GIT_TAG v3.5.3 16 | ) 17 | -------------------------------------------------------------------------------- /notes_on_cmake.txt: -------------------------------------------------------------------------------- 1 | mkdir visual_studio_2017 2 | cd visual_studio_2017 3 | cmake -G "Visual Studio 15 2017" .. 4 | cd .. 5 | 6 | Then open the .sln file in visual_studio_2017 7 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME StarterProject.tests) 2 | set(CMAKE_CXX_STANDARD 14) 3 | set(SOURCE_FILES 4 | main.cpp 5 | DemoTest.cpp 6 | NewTest.cpp 7 | Tutorial.cpp) 8 | add_executable(${TEST_NAME} ${SOURCE_FILES}) 9 | target_link_libraries(${TEST_NAME} StarterProject.code ApprovalTests::ApprovalTests Catch2::Catch2WithMain) 10 | target_compile_definitions(${TEST_NAME} PRIVATE -DAPPROVAL_TESTS_HIDE_DEPRECATED_CODE=1) 11 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 12 | 13 | #if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") 14 | # target_compile_options(StarterProject.tests PRIVATE 15 | # /W4 16 | # /WX 17 | # ) 18 | #elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") 19 | # target_compile_options(StarterProject.tests PRIVATE 20 | # -Wall 21 | # -Wextra 22 | # -Wpedantic 23 | # -Werror 24 | # ) 25 | #elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 26 | # string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 27 | # target_compile_options(StarterProject.tests PRIVATE 28 | # /W4 29 | # /WX 30 | # ) 31 | #endif() 32 | -------------------------------------------------------------------------------- /tests/DemoTest.DemoCombinationTestCase.approved.txt: -------------------------------------------------------------------------------- 1 | (2, 1) => value1: 2, value2: 1 2 | (2, 3) => value1: 2, value2: 3 3 | (2, 5) => value1: 2, value2: 5 4 | (2, 7) => value1: 2, value2: 7 5 | (2, 9) => value1: 2, value2: 9 6 | (4, 1) => value1: 4, value2: 1 7 | (4, 3) => value1: 4, value2: 3 8 | (4, 5) => value1: 4, value2: 5 9 | (4, 7) => value1: 4, value2: 7 10 | (4, 9) => value1: 4, value2: 9 11 | (6, 1) => value1: 6, value2: 1 12 | (6, 3) => value1: 6, value2: 3 13 | (6, 5) => value1: 6, value2: 5 14 | (6, 7) => value1: 6, value2: 7 15 | (6, 9) => value1: 6, value2: 9 16 | (8, 1) => value1: 8, value2: 1 17 | (8, 3) => value1: 8, value2: 3 18 | (8, 5) => value1: 8, value2: 5 19 | (8, 7) => value1: 8, value2: 7 20 | (8, 9) => value1: 8, value2: 9 21 | (10, 1) => value1: 10, value2: 1 22 | (10, 3) => value1: 10, value2: 3 23 | (10, 5) => value1: 10, value2: 5 24 | (10, 7) => value1: 10, value2: 7 25 | (10, 9) => value1: 10, value2: 9 26 | 27 | -------------------------------------------------------------------------------- /tests/DemoTest.DemoSimpleTestCase.approved.txt: -------------------------------------------------------------------------------- 1 | Some 2 | Multi-line 3 | output 4 | -------------------------------------------------------------------------------- /tests/DemoTest.cpp: -------------------------------------------------------------------------------- 1 | #define APPROVAL_TESTS_HIDE_DEPRECATED_CODE 1 2 | 3 | #include "ApprovalTests.hpp" 4 | #include "catch2/catch_test_macros.hpp" 5 | #include 6 | 7 | using namespace ApprovalTests; 8 | 9 | TEST_CASE("DemoSimpleTestCase") 10 | { 11 | Approvals::verify("Some\nMulti-line\noutput"); 12 | } 13 | 14 | struct Demo 15 | { 16 | int value1; 17 | int value2; 18 | 19 | // See https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/ToString.md#top 20 | friend std::ostream& operator<<(std::ostream& os, const Demo& obj) 21 | { 22 | return os << "value1: " << obj.value1 << ", value2: " << obj.value2; 23 | } 24 | }; 25 | 26 | TEST_CASE("DemoCombinationTestCase") 27 | { 28 | // See https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/TestingCombinations.md#top 29 | std::vector evens{2, 4, 6, 8, 10}; 30 | std::vector odds{1, 3, 5, 7, 9}; 31 | CombinationApprovals::verifyAllCombinations( 32 | [](int i, int j) { 33 | return Demo{i, j}; 34 | }, 35 | evens, 36 | odds); 37 | } 38 | -------------------------------------------------------------------------------- /tests/NewTest.ApprovingText.approved.txt: -------------------------------------------------------------------------------- 1 | Approval Tests can verify text via the golden master method 2 | -------------------------------------------------------------------------------- /tests/NewTest.ApprovingWithReporters.approved.txt: -------------------------------------------------------------------------------- 1 | Reporters launch only on failure, by default they are the DiffReporter 2 | -------------------------------------------------------------------------------- /tests/NewTest.cpp: -------------------------------------------------------------------------------- 1 | #define APPROVAL_TESTS_HIDE_DEPRECATED_CODE 1 2 | 3 | #include "ApprovalTests.hpp" 4 | #include "catch2/catch_test_macros.hpp" 5 | 6 | using namespace ApprovalTests; 7 | 8 | // All these tests should pass on your system. 9 | // Please note that you will need a Diff Tool installed: 10 | // https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Reporters.md#supported-diff-tools 11 | 12 | TEST_CASE("ApprovingText") 13 | { 14 | Approvals::verify( 15 | "Approval Tests can verify text via the golden master method "); 16 | } 17 | 18 | TEST_CASE("ApprovingWithReporters") 19 | { 20 | // See https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Options.md#top 21 | // you can alter this to make the test fail and launch a diff tool: 22 | Approvals::verify("Reporters launch only on failure, by default they are " 23 | "the DiffReporter", 24 | Options(DiffReporter())); 25 | } 26 | 27 | TEST_CASE("Approval Is just an assertion library, you don't need to use it.") 28 | { 29 | REQUIRE(std::string("No Approvals, only Catch") == 30 | "No Approvals, only Catch"); 31 | } 32 | -------------------------------------------------------------------------------- /tests/Tutorial.cpp: -------------------------------------------------------------------------------- 1 | #include "ApprovalTests.hpp" 2 | #include "catch2/catch_test_macros.hpp" 3 | 4 | // See the tutorial at: 5 | // https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Tutorial.md#top 6 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | #define APPROVALS_CATCH2_V3 2 | #include "ApprovalTests.hpp" 3 | --------------------------------------------------------------------------------