doctest

FORK: The fastest feature-rich C++11/14/17/20 single-header testing framework
git clone https://git.neptards.moe/neptards/doctest.git
Log | Files | Refs | README

main.cpp (901B)


      1 #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
      2 #include <doctest/doctest.h>
      3 
      4 #include "dll.h"
      5 
      6 int main(int argc, char **argv) {
      7     doctest::Context context;
      8     context.applyCommandLine(argc, argv);
      9     
     10     int res = context.run(); // run doctest
     11     
     12     // important - query flags (and --exit) rely on the user doing this
     13     if (context.shouldExit()) {
     14         // propagate the result of the tests
     15         return res;
     16     }
     17     
     18     say_hello_dll(); // test dll func
     19 }
     20 
     21 int square(const int number) { return number * number; }
     22 
     23 TEST_CASE("testing the square function") {
     24     CHECK(square(2) == 4);
     25     CHECK(square(4) == 16);
     26     CHECK(square(5) == 25);
     27     CHECK(square(8) == 64);
     28 }
     29 
     30 // running notes
     31 // ./example_dll --no-run (run normal program)
     32 // ./example_dll --exit (run tests then exit)
     33 // ./example_dll (run tests then run program)
     34 // ./example_dll --success (print successful test casts)