Add test framework and some basic unit tests #9038
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Tests for new and existing code will make development & refactoring easier.
And will make it easier to detect regressions and unintended changes.
Description
Added Catch2 header only test framework.
Math tests from #7796
Limitations
Prototype implementation to get feedback
Catch2 doesn't seem to be available in the Ubuntu 20.04 package repository
CMake FetchContent could be used instead: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
My CMake knowledge is to limited and/or the OpenTTD CMake setup is to advanced for me to do a correct test target integration. The current solution with CMake arguments is not ideal.
Other options, in 'quality' order
has the advantage of a single compile for most of the sources
two compiles, but no manual action needed to keep in sync
lots of dependencies make it hard to include all the required files, manual updates needed for new files