blob: a1ce58274b0b87ad541cdf78c52fc848f668b2a6 [file] [log] [blame]
onqtamc223b692016-08-02 17:20:06 +03001#define DOCTEST_CONFIG_COLORS_NONE // the easy way to fix code coverage
onqtamcc9e8652016-08-02 14:23:38 +03002#define DOCTEST_CONFIG_IMPLEMENT
onqtamc223b692016-08-02 17:20:06 +03003#include "parts/doctest_impl.h"
onqtamcc9e8652016-08-02 14:23:38 +03004
onqtam30c5e4b2016-08-02 16:10:22 +03005// intentionally here so there are subcases on the same lines in different files
onqtamd9bb03a2016-08-02 15:32:49 +03006TEST_CASE("subcases") {
7 SUBCASE("1") {
8 SUBCASE("1.1") {}
9 SUBCASE("1.2") {}
onqtam30c5e4b2016-08-02 16:10:22 +030010 SUBCASE("1.2") {}
onqtamd9bb03a2016-08-02 15:32:49 +030011 }
onqtam30c5e4b2016-08-02 16:10:22 +030012 // clang-format off
13 SUBCASE("2") {} SUBCASE("3") {} // to have subcases on the same line with different names
14 // clang-format on
onqtamd9bb03a2016-08-02 15:32:49 +030015}
16
17#include <iostream>
18
19using namespace std;
20
21using doctest::toString;
22
onqtam30c5e4b2016-08-02 16:10:22 +030023TEST_CASE("doctest internals") {
24 // string stuff
onqtamd9bb03a2016-08-02 15:32:49 +030025 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);
onqtamc223b692016-08-02 17:20:06 +030032 CHECK(a.compare("omgomgomg", false) == 0);
onqtamd9bb03a2016-08-02 15:32:49 +030033
onqtam30c5e4b2016-08-02 16:10:22 +030034 // toString
onqtamc223b692016-08-02 17:20:06 +030035 cout << toString("aaa") << toString(0.5f) << toString('c') << toString(true)
onqtamd9bb03a2016-08-02 15:32:49 +030036 << 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));
onqtam30c5e4b2016-08-02 16:10:22 +030042
43 // others
44 cout << doctest::detail::fileForOutput("c:\\a") << doctest::detail::fileForOutput("c:/a")
45 << doctest::detail::fileForOutput("a");
onqtam4321fd82016-08-02 14:59:17 +030046}
onqtamcc9e8652016-08-02 14:23:38 +030047
onqtam4321fd82016-08-02 14:59:17 +030048int 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");
onqtamcc9e8652016-08-02 14:23:38 +030054
55 context.applyCommandLine(argc, argv);
56
onqtam4321fd82016-08-02 14:59:17 +030057 int res = context.run();
onqtamcc9e8652016-08-02 14:23:38 +030058
onqtam4321fd82016-08-02 14:59:17 +030059 if(context.shouldExit())
60 return res;
onqtamcc9e8652016-08-02 14:23:38 +030061
onqtam4321fd82016-08-02 14:59:17 +030062 return res;
onqtamcc9e8652016-08-02 14:23:38 +030063}