The fastest feature-rich C++11/14/17/20 single-header testing framework

Overview

master branch Windows All
dev branch Windows All

doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as D / Rust / Nim to have tests written directly in the production code thanks to a fast, transparent and flexible test runner with a clean interface.

Standard License Version download CII Best Practices Language grade: C/C++ Join the chat at https://gitter.im/onqtam/doctest Try it online

The framework is and will stay free but needs your support to sustain its development. There are lots of new features and maintenance to do. If you work for a company using doctest or have the means to do so, please consider financial support. Monthly donations via Patreon and one-offs via PayPal.

A complete example with a self-registering test that compiles to an executable looks like this:

cover-example

There are many C++ testing frameworks - Catch, Boost.Test, UnitTest++, cpputest, googletest and many other.

The key differences between it and other testing frameworks are that it is light and unintrusive:

  • Ultra light on compile times both in terms of including the header and writing thousands of asserts
  • Doesn't produce any warnings even on the most aggressive warning levels for MSVC/GCC/Clang
  • Offers a way to remove everything testing-related from the binary with the DOCTEST_CONFIG_DISABLE identifier
  • thread-safe - asserts (and logging) can be used from multiple threads spawned from a single test case - example
  • asserts can be used outside of a testing context - as a general purpose assert library - example
  • Doesn't pollute the global namespace (everything is in namespace doctest) and doesn't drag any headers with it
  • Very portable C++11 (use tag 1.2.9 for C++98) with over 180 different CI builds (static analysis, sanitizers...)
  • binaries (exe/dll) can use the test runner of another binary - so tests end up in a single registry - example

cost-of-including-the-framework-header

This allows the framework to be used in more ways than any other - tests can be written directly in the production code!

Tests can be considered a form of documentation and should be able to reside near the production code which they test.

  • This makes the barrier for writing tests much lower - you don't have to: 1) make a separate source file 2) include a bunch of stuff in it 3) add it to the build system and 4) add it to source control - You can just write the tests for a class or a piece of functionality at the bottom of its source file - or even header file!
  • Tests in the production code can be thought of as documentation or up-to-date comments - showing the use of APIs
  • Testing internals that are not exposed through the public API and headers is no longer a mind-bending exercise
  • Test-driven development in C++ has never been easier!

The framework can be used like any other if you don't want/need to mix production code and tests - check out the features.

doctest is modeled after Catch and some parts of the code have been taken directly - check out the differences.

This table compares doctest / Catch / lest which are all very similar.

Checkout the CppCon 2017 talk on YouTube to get a better understanding of how the framework works and read about how to use it in the JetBrains article - highlighting the unique aspects of the framework! On a short description on how to use the framework along production code you could refer to this GitHub issue. There is also an older article in the february edition of ACCU Overload 2017.

CppCon 2017 talk about doctest on youtube

Documentation

Project:

Usage:

Contributing

Support the development of the project with donations! There is a list of planned features which are all important and big - see the roadmap. I took a break from working in the industry to make open source software so every cent is a big deal.

If you work for a company using doctest or have the means to do so, please consider financial support.

Contributions in the form of issues and pull requests are welcome as well - check out the Contributing page.

Stargazers over time

Stargazers over time

Logo

The logo is licensed under a Creative Commons Attribution 4.0 International License. Copyright © 2019 area55git   License: CC BY 4.0

Issues
  • Add Github Actions CI

    Add Github Actions CI

    Opening the pull request so I can start testing the configuration. I've started by taking reproc's Github Actions configuration and removing everything reproc related. Once that works I'll start adding all doctest related configuration.

    opened by DaanDeMeyer 38
  • Regression between 2.4.6 and 2.4.7

    Regression between 2.4.6 and 2.4.7

    Description

    Following minimized code works perfectly on 2.4.6, but fails on 2.4.7

    // #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN shouldn't be defined in compilation unit to reproduce
    #include <doctest/doctest.h>
    
    #include <string>
    
    namespace {
    
    class B
    {
    public:
        const std::string& getName() const
        {
            return m_name;
        }
    
        std::string m_name = "B";
    };
    
    }  // namespace
    
    TEST_CASE("Wtf?") {
        B b;
    
        CHECK(b.getName() == "B");
    }
    

    https://godbolt.org/z/Eq48fjsed (due to the godbolt limitations see "undefined reference to `main'" linker warnings as success)

    Flags: "-std=c++11 -Wall -Wextra -Wpedantic -Werror"

    It fails on GCC version 4.9 - 10.3 with -fpermissive warning. (GCC version 11.2 compiles it without a problem though 🤔)

    doctest/doctest.h: In instantiation of 'void doctest::detail::fillstream(const T (&)[N]) [with T = char; long unsigned int N = 2]':
    doctest/doctest.h:904:31:   required from 'static void doctest::detail::filldata<T [N]>::fill(const T (&)[N]) [with T = const char; long unsigned int N = 2]'
    doctest/doctest.h:918:65:   required from 'void doctest::detail::filloss(const T (&)[N]) [with T = char; long unsigned int N = 2]'
    doctest/doctest.h:933:20:   required from 'static doctest::String doctest::detail::StringMakerBase<true>::convert(const T&) [with T = char [2]]'
    doctest/doctest.h:978:35:   required from 'doctest::String doctest::toString(const T&) [with T = char [2]; typename doctest::detail::enable_if<(! doctest::detail::is_enum<T>::value), bool>::type <anonymous> = true]'
    doctest/doctest.h:1142:45:   required from 'doctest::String doctest::detail::stringifyBinaryExpr(const L&, const char*, const R&) [with L = std::__cxx11::basic_string<char>; R = char [2]]'
    doctest/doctest.h:1320:9:   required from 'decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) doctest::detail::Expression_lhs<L>::operator==(const R&) [with R = char [2]; typename doctest::detail::enable_if<(! doctest::detail::is_rvalue_reference<R>::value), void>::type* <anonymous> = 0; L = const std::__cxx11::basic_string<char>&; decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) = doctest::detail::Result]'
    <source>:24:5:   required from here
    doctest/doctest.h:896:31: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char, std::char_traits<char> >'} and 'const char')
    doctest/doctest.h:557:33: note: candidate: 'std::ostream& doctest::operator<<(std::ostream&, const doctest::String&)' (near match)
    doctest/doctest.h:557:33: note:   conversion of argument 2 would be ill-formed:
    doctest/doctest.h:896:36: error: invalid user-defined conversion from 'const char' to 'const doctest::String&' [-fpermissive]
    doctest/doctest.h:519:5: note: candidate is: 'doctest::String::String(const char*)' (near match)
    doctest/doctest.h:519:5: note:   conversion of argument 1 would be ill-formed:
    doctest/doctest.h:896:36: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    doctest/doctest.h:896:36: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    doctest/doctest.h:519:24: note:   initializing argument 1 of 'doctest::String::String(const char*)'
    In file included from /opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/string:55,
                     from <source>:4:
    /opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/basic_string.h:6468:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
     6468 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
          |     ^~~~~~~~
    /opt/compiler-explorer/gcc-10.3.0/include/c++/10.3.0/bits/basic_string.h:6468:5: note:   template argument deduction/substitution failed:
    doctest/doctest.h:896:31: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char'
    

    It fails on any version of clang, but with an error instead of the warning. It fails on MSVC at least in version 19 that is accessible on Godbolt.

    Using this code as a test, it's possible to bisect a broken commit.

    opened by YarikTH 28
  • Tests inside a static library

    Tests inside a static library

    Hi,

    (This is more a question than an issue) What is the recommended way to add tests inside a static library project ?

    If I compile a library (which includes TEST_CASE(s)) as a static library, and then I try to run the tests from this library by creating a target that links to it, the test suite is actually empty (i.e I guess the tests were stripped at link time)

    Am I doing something wrong, or is there a way to circumvent this?

    Below is an example of what I am trying to achieve (using cmake):

    Project         <- main project
      CMakeLists.txt
      doctest/
        doctest.h
        doctest_main.cpp
      MyLibrary/
        lib1.cpp    <- these files includes actual library code and TEST_CASE(s)
        lib2.cpp    
        lib3.cpp    
        CMakeLists.txt <- will produce two targets : library and its test
      MyMainProgram/
        main.cpp
        CMakeLists.txt
    
    

    MyLibrary/CMakeLists.txt :

        set(sources lib1.cpp lib2.cpp lib3.cpp)
        add_library(MyLibrary STATIC ${sources})
        target_include_directories(MyLibrary PUBLIC ${CMAKE_SOURCE_DIR}/doctest )
    
        # This does not work : it links but the test list is empty !
        add_executable(MyLibrary_DocTest ${CMAKE_SOURCE_DIR}/doctest/doctest_main.cpp)
        target_link_libraries(MyLibrary_DocTest MyLibrary)
    
        # This works, but it requires to re-compile all the source files and to re-define
        # exactly the same compile options as for the library (linked library, compile definition, etc); 
        # this can be tedious
        add_executable(MyLibrary_DocTest ${sources} ${CMAKE_SOURCE_DIR}/doctest/doctest_main.cpp)
    
    

    MyMainProgram/CMakeLists.txt :

        add_executable(MyMainProgram main.cpp)
        target_link_libraries(MyMainProgram MyLibrary)
    

    A working example can be found at https://github.com/pthom/DocTest_LibTest

    opened by pthom 27
  • Count points based on the number of passed/failed cases?

    Count points based on the number of passed/failed cases?

    Hi guys, I am now trying to use doctest to grade c++ code assignments, and this is my first time to use doctest. Just one question, is there any way that I can count the points based on how many testcases are passed? Or is there any way that I can perform like IF test case passed, THEN grade ++, something like that?

    Thanks a lot!

    opened by xrb936 24
  • Doctest is not able to compile on OSX

    Doctest is not able to compile on OSX

    Description

    I am trying to get my Travis CI build working with doctest (I'm switching from Catch to this for performance), but my build is not working on OSX (It is for Linux). In my Travis CI logs, I see the following error:

    Undefined symbols for architecture x86_64:
      "std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
          doctest::String doctest::detail::stringifyBinaryExpr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [6]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*, char const (&) [6]) in hello_world_test.cpp.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [test/test_runner] Error 1
    make[1]: *** [test/CMakeFiles/test_runner.dir/all] Error 2
    make: *** [all] Error 2
    

    Steps to reproduce

    I'm using CMake, and my invocation command is:

    cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=$COMPILER -DBUILD_TESTS=ON ..
    

    (COMPILER is set to clang++ and BUILD_TYPE is set to Debug and Release, both of which fail)

    The CMake configuration I am using is (for flags):

    if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
        set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
    elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
        # ...
    endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    

    And the test configuration:

    set(TEST_SOURCES
        factorial_test.cpp
        hello_world_test.cpp
    )
    
    add_library(doctest INTERFACE)
    target_include_directories(doctest INTERFACE 
        "${CMAKE_SOURCE_DIR}/third_party/doctest" # Contains single header
    )
    
    add_executable(test_runner test_runner.cpp ${TEST_SOURCES})
    target_link_libraries(test_runner Project-Name-lib doctest)
    
    add_test(all_tests test_runner)
    

    Extra information

    • doctest version: v1.2.8
    • Operating System: Travis CI OSX XCode image 9.2
    • Compiler+version: AppleClang 9.0.0.9000039
    opened by arnavb 23
  • Add default printers for enums

    Add default printers for enums

    I've added an assertion for a function returning an enum and the enum value. When the test failed I've got pretty informative failure output {?} == {?}...

    I don't intend to write a custom printer for my enum type, but still want to see readable values when a test fails. I've workaround the problem by casting to int, but I'd prefer if the library does this for me.

    opened by obfuscated 22
  • Logo Proposal for Doctest

    Logo Proposal for Doctest

    Hi, In response to your request for Logo, I am very grateful to be able to collaborate in your project.

    I need a short review about Doctest to start with the sketches. I can improve the existing one or create something totally new and different. You can tell me your suggestions.

    opened by area55git 20
  • [Feature] Better integration with tools (VS Code Test Adapter Extension)

    [Feature] Better integration with tools (VS Code Test Adapter Extension)

    Description

    The "Catch2 and Google Test Explorer" Extension for Visual Studio Code has experimental support for doctest. However, several tests with the same name but in different tests suites can't be run. Also, the test results can't be displayed reliably inline in the source code. This could be fixed if some additional information was available from the command line.

    Could you add the possibility to list the test suites and test cases with file names and line numbers from the command line?

    This would make it possible for the extension to work reliably and give VS Code users much better usability while using doctest.

    See: https://github.com/matepek/vscode-catch2-test-adapter/issues/143#issuecomment-566092840 And: https://github.com/matepek/vscode-catch2-test-adapter/issues/143#issuecomment-566139062

    opened by wilhem-meignan 19
  • Slower than Catch in realistic test cases

    Slower than Catch in realistic test cases

    Hi,

    I did some benchmarking of doctest on my machine (Linux, gcc-4.9.3). I adapted a bit your Python script to work on Linux (with_gcc = 1 and removed the forced CMake generator).

    First, I can confirm that in the simple benchmark case, it is indeed faster to compile than Catch by a large margin. However, this is not a very realistic test case.

    I have modified the benchmark to generate 50 files, each with 25 test cases and each with 10 CHECK (using a variable and not two constants). Here are the results:

    Catch: 1 minute 56 seconds Doctest: 2 minutes 32 seconds

    In a realistic test case, doctest is significantly slower than Catch. I can see the same thing when I replace Catch by doctest in one of my large test case of my ETL library.

    Do you have any idea why this happen ?

    I can only guess that the overhead comes from the templates used to extract lhs and rhs or by the macros generating the test cases.

    opened by wichtounet 19
  • [PROJECT ANNOUNCEMENT] Looking for maintainers for Doctest

    [PROJECT ANNOUNCEMENT] Looking for maintainers for Doctest

    Working on doctest has taught me two very important lessons: how to prioritize and how to say no, and now it's time to apply them to my life. I can no longer maintain doctest properly and that's evident by my inactivity for the past 8 months - I haven't touched C++ professionally in almost 2 years and I've moved on to other things.

    I invite anyone interested in the development & maintenance of the framework to join the Discord server. I just moved doctest to a GitHub organization as suggested here and will add whoever is interested as a member. I'll release a version or two and will stick around for some time as people join in order to resolve any disputes and respond to questions and at some point, I'll promote the ones that have shown the most interest to admins & owners of the repository and the Discord server - I won't leave but I hope that by that time others would be able to reach consensus on contentious issues and I'll redirect any donations to the maintainers once this transition period is over.

    Doctest doesn't require too much work (unless new features are added) - mostly the occasional compiler bugfix & support in issues. The design goals of the framework should be followed - what made doctest successful is the art of saying no and keeping it light & easy to use.

    EDIT: some more info - https://github.com/doctest/doctest/issues/554#issuecomment-991190934

    Best regards, Viktor

    opened by onqtam 18
  • Refactor stringification

    Refactor stringification

    So StringMaker and StringStream act as a pretty much completely parallel structure. This structure will be eradicated. For the first draft I have simply removed the StringMaker's body, attaching it's head to StringStream's body.

    The customization points are broken, as well as a few other features, namely raw memory stringification likely among others.

    This (hopefully) finally fixes #571 for good!

    opened by Saalvage 16
  • Updating from v2.4.8 to v2.4.9 broke code on Ubuntu Focal on GitLab Runner: asm in constexpr function

    Updating from v2.4.8 to v2.4.9 broke code on Ubuntu Focal on GitLab Runner: asm in constexpr function

    Description

    Updating doctest from commit 7b9885133108ae301ddd16e2651320f54cafeba7 (v2.4.8) to b7c21ec5ceeadb4951b00396fc1e4642dd347e5f (v2.4.9) broke my code on Ubuntu Focal in a Docker container running on GitLab Runner for my repo. The error looks like this:

    [ 28%] Building CXX object test/CMakeFiles/unit_test.dir/active_list/active_list_test.cpp.o
    In file included from /builds/tunococ/funnel/test/active_list/active_list_test.cpp:1:
    /builds/tunococ/funnel/test/active_list/probes.hpp: In static member function 'static constexpr void funnel::active_list::Probe<void>::check(ActiveList&)':
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:438:39: error: 'asm' in 'constexpr' function
      438 | #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler)
          |                                       ^~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2095:17: note: in expansion of macro 'DOCTEST_BREAK_INTO_DEBUGGER'
     2095 |     if(b.log()) DOCTEST_BREAK_INTO_DEBUGGER();                                                     \
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:23[64](https://gitlab.com/tunococ/funnel/-/jobs/2824026751#L64):9: note: in expansion of macro 'DOCTEST_ASSERT_LOG_REACT_RETURN'
     2364 |         DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB);                                               \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2415:33: note: in expansion of macro 'DOCTEST_BINARY_ASSERT'
     2415 | #define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__)
          |                                 ^~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2976:25: note: in expansion of macro 'DOCTEST_REQUIRE_EQ'
     2976 | #define REQUIRE_EQ(...) DOCTEST_REQUIRE_EQ(__VA_ARGS__)
          |                         ^~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/test/active_list/probes.hpp:25:9: note: in expansion of macro 'REQUIRE_EQ'
       25 |         REQUIRE_EQ(index, active_index);
          |         ^~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:438:39: error: 'asm' in 'constexpr' function
      438 | #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler)
          |                                       ^~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2095:17: note: in expansion of macro 'DOCTEST_BREAK_INTO_DEBUGGER'
     2095 |     if(b.log()) DOCTEST_BREAK_INTO_DEBUGGER();                                                     \
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2364:9: note: in expansion of macro 'DOCTEST_ASSERT_LOG_REACT_RETURN'
     2364 |         DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB);                                               \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2424:33: note: in expansion of macro 'DOCTEST_BINARY_ASSERT'
     2424 | #define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__)
          |                                 ^~~~~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/external/doctest/doctest/doctest.h:2985:25: note: in expansion of macro 'DOCTEST_REQUIRE_LT'
     2985 | #define REQUIRE_LT(...) DOCTEST_REQUIRE_LT(__VA_ARGS__)
          |                         ^~~~~~~~~~~~~~~~~~
    /builds/tunococ/funnel/test/active_list/probes.hpp:29:7: note: in expansion of macro 'REQUIRE_LT'
       29 |       REQUIRE_LT(index, active_index);
          |       ^~~~~~~~~~
    

    (This is an excerpt from here.)

    I ran into this when I tried to create a merge request to update doctest.

    Steps to reproduce

    So far I can only see this failure on my GitLab CI. I cannot reproduce this on my Chromebook even with the same docker image. Well, it's not exactly the same docker image because my Chromebook has a different architecture from GitLab's machines. So this issue is likely architecture-dependent.

    You can try to test this on your machine by cloning my repo, checking out the branch tunococ/update-doctest, and running script/unit_test_docker.sh -I ubuntu from the root of the repository.

    Extra information

    • doctest version: v2.4.9
    • Operating System: Ubuntu Focal
    • Compiler+version: GCC 9.4.0

    The main branch on my repo does not have this error because it still uses version 2.4.8.

    opened by tunococ 0
  • Optimized code structure

    Optimized code structure

    Dear, sir

    Fixed linker error by restructuring the code when tried to use cmake to integrate doctest with mpi.

    In origin file:

    #ifdef DOCTEST_CONFIG_IMPLEMENT
    // declarations and definitions, like
    int mpi_comm_world_size();
    // skip
    int mpi_comm_world_size() {
    // skip
    }
    #else
    // only declarations
    int mpi_comm_world_size(); // no definition
    //skip
    #define MPI_CHECK // define some macro for mpi test
    // ...
    #endif
    

    So we have to define DOCTEST_CONFIG_IMPLEMENT to get the function definitions and get macro without DOCTEST_CONFIG_IMPLEMENT defined and then link them. I don't think this approach is good enough for some tests, for example if there is only one file here. That's what I think is wrong.

    opened by jokervTv 1
  • enums with ostream<< overloads are printed as their underlying type (as integers)

    enums with ostream<< overloads are printed as their underlying type (as integers)

    Description

    I had some enums where I defined an ostream<< operator, and I want to use it to print my enums rather than printing their underlying value like doctest seems to do by default.

    Steps to reproduce

    enum class Foo {};
    
    std::ostream& operator<<(std::ostream& os, Foo) {
      return os << "Foo";
    }
    
    int main() {
        assert(doctest::toString(Foo()) == "Foo"); // Fails, toString returns "0"
    }
    

    (disclaimer: I have not tested the example code above.)

    Extra information

    I found a workaround but it only works for GCC (see: https://github.com/doctest/doctest/issues/121#issuecomment-1200039472)

    I suggest to tweak doctest's enum printing code so that it only prints enums by their underlying type if they do not meet the requirements of has_insertion_operator.

    opened by nlguillemot 0
  • Reorganising the MPI code and adding a default main() entry to the MPI

    Reorganising the MPI code and adding a default main() entry to the MPI

    Dear, sir

    • Fixed linker error by restructuring the code when tried to use cmake to integrate doctest with mpi.
    • Standardising the style of the code using project .clang-format.
    • Used 'Include Guards' instead of #program once to improve compatibility.
    • Added macro DOCTEST_CONFIG_IMPLEMENT_WITH_MPI_MAIN to provide a default main entry for mpi tests.
    • Markdown documentation has also been updated.

    Thanks for open sourcing this useful library.

    opened by jokervTv 5
  • (v2.4.8) Log output does not automatically create directory when it doesn't exist

    (v2.4.8) Log output does not automatically create directory when it doesn't exist

    Description

    When running with -r=junit -o=reports/log.xml, if reports folder does not exist, no xml file will be actually generated. I am not sure what's behind this behavior, but gtest framework will create the folder if it doesn't exist.

    Steps to reproduce

    just run the exe with -r=junit -o=reports/log.xml

    Extra information

    • doctest version: v2.4.8
    • Operating System: ubuntu 18.04
    • Compiler+version: gcc 7.5
    opened by OneOfTheirs 3
Releases(v2.4.9)
Owner
Viktor Kirilov
Working on Nimbus - an Ethereum 1.0 & 2.0 Client for Resource-Restricted Devices.
Viktor Kirilov
A unit testing framework for C

Check Table of Contents About Installing Linking Packaging About Check is a unit testing framework for C. It features a simple interface for defining

null 892 Jul 29, 2022
CppUTest unit testing and mocking framework for C/C++

CppUTest CppUTest unit testing and mocking framework for C/C++ More information on the project page Slack channel: Join if link not expired Getting St

CppUTest 1.1k Aug 8, 2022
A testing micro framework for creating function test doubles

Fake Function Framework (fff) A Fake Function Framework for C Hello Fake World! Capturing Arguments Return Values Resetting a Fake Call History Defaul

Mike Long 499 Aug 3, 2022
Googletest - Google Testing and Mocking Framework

GoogleTest OSS Builds Status Announcements Release 1.10.x Release 1.10.x is now available. Coming Soon Post 1.10.x googletest will follow Abseil Live

Google 27.2k Aug 11, 2022
Minimal unit testing framework for C

MinUnit Minunit is a minimal unit testing framework for C/C++ self-contained in a single header file. It provides a way to define and configure test s

David Siñuela Pastor 429 Aug 8, 2022
A lightweight unit testing framework for C++

Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 26 November 2020. Subscribe to https://github.com/unittest-cpp/unittest-cp

UnitTest++ 503 Aug 5, 2022
UT: C++20 μ(micro)/Unit Testing Framework

"If you liked it then you "should have put a"_test on it", Beyonce rule [Boost::ext].UT / μt | Motivation | Quick Start | Overview | Tutorial | Exampl

boost::ext 888 Aug 7, 2022
🍦IceCream-Cpp is a little (single header) library to help with the print debugging on C++11 and forward.

??IceCream-Cpp is a little (single header) library to help with the print debugging on C++11 and forward.

Renato Garcia 388 Aug 2, 2022
Simple Unit Testing for C

Unity Test Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams Welcome to the Unity Test Project, one of the

Throw The Switch 2.6k Aug 11, 2022
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Catch Org 15.4k Aug 11, 2022
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Catch Org 15.4k Aug 8, 2022
Single C file, Realtime CPU/GPU Profiler with Remote Web Viewer

Remotery A realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser. Supported Platforms: Windows Windows UWP (Hol

Celtoys 2.3k Aug 8, 2022
C++ Benchmark Authoring Library/Framework

Celero C++ Benchmarking Library Copyright 2017-2019 John Farrier Apache 2.0 License Community Support A Special Thanks to the following corporations f

John Farrier 711 Jul 29, 2022
A C++ micro-benchmarking framework

Nonius What is nonius? Nonius is an open-source framework for benchmarking small snippets of C++ code. It is very heavily inspired by Criterion, a sim

Nonius 334 Jun 27, 2022
test framework

Photesthesis This is a small, experimental parameterized-testing tool. It is intended to be used in concert with another unit-testing framework (eg. C

Graydon Hoare 11 Jun 2, 2021
A simple framework for compile-time benchmarks

Metabench A simple framework for compile-time microbenchmarks Overview Metabench is a single, self-contained CMake module making it easy to create com

Louis Dionne 162 Jul 8, 2022
The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch Windows All dev branch Windows All doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of

Viktor Kirilov 4.1k Aug 12, 2022
The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch dev branch doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime c

null 4.1k Aug 7, 2022
A modern, feature-rich single header C++ interface system for GLFW

A modern, feature-rich single header C++ interface system for GLFW

Vortex 3 Dec 27, 2021
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

null 6.4k Aug 10, 2022
C++ Unit Testing Easier: A Header-only C++ unit testing framework

CUTE C++ Unit Testing Easier: A Header-only C++ unit testing framework usually available as part of the Cevelop C++ IDE (http://cevelop.com) Dependenc

Peter Sommerlad 34 Jul 22, 2022
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri

null 2.2k Aug 5, 2022
Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable executables. Has a modern C++ wrapper.

memscan Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable

cristei 13 Aug 11, 2022
Simple, fully external, smart, fast, JSON-configurated, feature-rich Windows x86 DLL Memory Dumper with Code Generation. Written in Modern C++.

altdumper Simple, fully external, smart, fast, JSON-configurated, feature-rich Windows x86 DLL Memory Dumper with Code Generation. Written in Modern C

cristei 12 Jul 13, 2022
Rule Engine (RE) creates an interpretable anomaly classifier from many one-feature and two-feature decision rules

Rule Engine (RE) creates an interpretable anomaly classifier from many one-feature and two-feature decision rules

James Thomas 14 Jul 16, 2022
🧪 single header unit testing framework for C and C++

?? utest.h A simple one header solution to unit testing for C/C++. Usage Just #include "utest.h" in your code! The current supported platforms are Lin

Neil Henning 499 Aug 5, 2022
The C Unit Testing Library on GitHub is a library designed for easy unit testing in C

The C Unit Testing Library on GitHub is a library designed for easy unit testing in C. It was written by Brennan Hurst for the purpose of providing a J-Unit-like testing framework within C for personal projects.

null 1 Oct 11, 2021
A complete unit testing framework in a header

liblittletest A complete unit testing framework in a header liblittletest is an easy to use all-in-an-header testing framework; all you have to do in

Sebastiano Merlino 13 Nov 11, 2021
A single file, single function, header to make notifications on the PS4 easier

Notifi Synopsis Adds a single function notifi(). It functions like printf however the first arg is the image to use (NULL and any invalid input should

Al Azif 7 Mar 24, 2022