onqtam | c223b69 | 2016-08-02 17:20:06 +0300 | [diff] [blame^] | 1 | #define DOCTEST_CONFIG_COLORS_NONE // the easy way to fix code coverage |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 2 | #define DOCTEST_CONFIG_IMPLEMENT |
onqtam | c223b69 | 2016-08-02 17:20:06 +0300 | [diff] [blame^] | 3 | #include "parts/doctest_impl.h" |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 4 | |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 5 | // intentionally here so there are subcases on the same lines in different files |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 6 | TEST_CASE("subcases") { |
| 7 | SUBCASE("1") { |
| 8 | SUBCASE("1.1") {} |
| 9 | SUBCASE("1.2") {} |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 10 | SUBCASE("1.2") {} |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 11 | } |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 12 | // clang-format off |
| 13 | SUBCASE("2") {} SUBCASE("3") {} // to have subcases on the same line with different names |
| 14 | // clang-format on |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | #include <iostream> |
| 18 | |
| 19 | using namespace std; |
| 20 | |
| 21 | using doctest::toString; |
| 22 | |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 23 | TEST_CASE("doctest internals") { |
| 24 | // string stuff |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 25 | doctest::String a; |
| 26 | a += "omg"; |
| 27 | const doctest::String const_str("omgomgomg"); |
| 28 | a = const_str.c_str(); |
| 29 | CHECK(a.size() == const_str.size()); |
| 30 | CHECK(a.length() == const_str.length()); |
| 31 | CHECK(a.compare(const_str, true) == 0); |
onqtam | c223b69 | 2016-08-02 17:20:06 +0300 | [diff] [blame^] | 32 | CHECK(a.compare("omgomgomg", false) == 0); |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 33 | |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 34 | // toString |
onqtam | c223b69 | 2016-08-02 17:20:06 +0300 | [diff] [blame^] | 35 | cout << toString("aaa") << toString(0.5f) << toString('c') << toString(true) |
onqtam | d9bb03a | 2016-08-02 15:32:49 +0300 | [diff] [blame] | 36 | << toString(static_cast<long double>(0.1)) // |
| 37 | << toString(static_cast<unsigned char>(1)) // |
| 38 | << toString(static_cast<short>(1)) // |
| 39 | << toString(static_cast<long>(1)) // |
| 40 | << toString(static_cast<unsigned long>(1)) // |
| 41 | << toString(static_cast<unsigned short>(1)); |
onqtam | 30c5e4b | 2016-08-02 16:10:22 +0300 | [diff] [blame] | 42 | |
| 43 | // others |
| 44 | cout << doctest::detail::fileForOutput("c:\\a") << doctest::detail::fileForOutput("c:/a") |
| 45 | << doctest::detail::fileForOutput("a"); |
onqtam | 4321fd8 | 2016-08-02 14:59:17 +0300 | [diff] [blame] | 46 | } |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 47 | |
onqtam | 4321fd8 | 2016-08-02 14:59:17 +0300 | [diff] [blame] | 48 | int main(int argc, char** argv) { |
| 49 | doctest::Context context; |
| 50 | |
| 51 | context.addFilter("test-case-exclude", "*math*"); |
| 52 | context.setOption("no-breaks", true); |
| 53 | context.setOption("sort", "name"); |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 54 | |
| 55 | context.applyCommandLine(argc, argv); |
| 56 | |
onqtam | 4321fd8 | 2016-08-02 14:59:17 +0300 | [diff] [blame] | 57 | int res = context.run(); |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 58 | |
onqtam | 4321fd8 | 2016-08-02 14:59:17 +0300 | [diff] [blame] | 59 | if(context.shouldExit()) |
| 60 | return res; |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 61 | |
onqtam | 4321fd8 | 2016-08-02 14:59:17 +0300 | [diff] [blame] | 62 | return res; |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 63 | } |