make unit tests available in all debug builds

This commit is contained in:
Wengier
2021-11-23 06:09:22 -05:00
parent 8a3b5b7367
commit baaebd367b
9 changed files with 41 additions and 92 deletions

View File

@@ -18,22 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* This sample shows how to write a simple unit test for dosbox-staging using
* Google C++ testing framework.
*
* Read Google Test Primer for reference of most available features, macros,
* and guidance about writing unit tests:
*
* https://github.com/google/googletest/blob/master/googletest/docs/primer.md#googletest-primer
*/
/* Include necessary header files; order of headers should be as follows:
*
* 1. Header declaring functions/classes being tested
* 2. <gtest/gtest.h>, which declares the testing framework
* 3. Additional system headers (if needed)
* 4. Additional dosbox-staging headers (if needed)
*/
#if C_DEBUG
#include "../src/dos/drives.h"
@@ -163,3 +148,4 @@ TEST(Set_Label, InvalidCharsEndingDotCD)
}
} // namespace
#endif

9
tests/readme.txt Normal file
View File

@@ -0,0 +1,9 @@
Source files in this subdirectory contain unit tests.
They use GTest and GMock for running unit testing.
Unit tests can be launched with "dosbox-x -tests".
Free free to add more unit tests in this directory.
Read Google Test Primer for reference of most available
features, macros, and guidance about writing unit tests:
https://google.github.io/googletest/primer.html

View File

@@ -18,22 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* This sample shows how to write a simple unit test for dosbox-staging using
* Google C++ testing framework.
*
* Read Google Test Primer for reference of most available features, macros,
* and guidance about writing unit tests:
*
* https://github.com/google/googletest/blob/master/googletest/docs/primer.md#googletest-primer
*/
/* Include necessary header files; order of headers should be as follows:
*
* 1. Header declaring functions/classes being tested
* 2. <gtest/gtest.h>, which declares the testing framework
* 3. Additional system headers (if needed)
* 4. Additional dosbox-staging headers (if needed)
*/
#if C_DEBUG
#include "shell.h"
@@ -190,3 +175,4 @@ TEST_F(DOS_Shell_CMDSTest, CMD_ECHO_space_handling)
}
} // namespace
#endif

22
tests/tests.h Normal file
View File

@@ -0,0 +1,22 @@
#if C_DEBUG
// The following includes necessary GTest/GMock source files for unit tests.
// Launch DOSBox-X with -tests option in debug builds to run unit tests.
#include "../../tests/gmock/gmock-cardinalities.cc"
#include "../../tests/gmock/gmock-internal-utils.cc"
#include "../../tests/gmock/gmock-spec-builders.cc"
#include "../../tests/gmock/gmock.cc"
#include "../../tests/gtest/gtest-death-test.cc"
#include "../../tests/gtest/gtest-filepath.cc"
#include "../../tests/gtest/gtest-port.cc"
#include "../../tests/gtest/gtest-printers.cc"
#include "../../tests/gtest/gtest-test-part.cc"
#include "../../tests/gtest/gtest.cc"
// The following are source files containing unit tests.
#include "../../tests/drives_tests.cpp"
#include "../../tests/shell_cmds_tests.cpp"
#endif // DEBUG