Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Codechange: introduce a few unit tests #7254
There was some discussion about introducing unit tests to OpenTTD on irc. Here's a proof of concept with some unit tests for a few basic math functions.
To run these tests, you need to install Googletest. On Debian you can do an
There was some discussion about introducing unit tests to OpenTTD on irc. Here's a proof of concept with some unit tests for a few basic math functions. To run these tests, you need to install [Googletest](https://github.com/google/googletest). On Debian you can do an `apt install googletest`. Then you should be able to run them by going to the `test` directory and running `./test-all.sh`. If we go further down this route we can of course set these up with the CI stuff like Azure.
Hmm, the recommended way of integrating Googletest into the build system is actually to use CMake, as
Projects that integrate Googletest with autotools need to resort to one of these options, as far as I can tell:
None of those are particularly nice solutions. A fourth option lets CMake download and configure Googletest, like this:
This is all info from here, btw: https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project
So, as it stands, if we do want to integrate Googletest with autotools, we can either use a git submodule or include Googletest's source with OpenTTD. If anyone thinks those are good ideas I can move forward with that. Otherwise maybe it's better to wait on this until TrueBrain converts the build system over to CMake.