LCOV - code coverage report
Current view: top level - test - derived.cpp (source / functions) Hit Total Coverage
Test: coverage_report.info.cleaned Lines: 10 10 100.0 %
Date: 2019-04-29 18:07:40 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include <cpp_template/derived.hpp>
       2             : #include <doctest/doctest.h>
       3             : 
       4             : #include <memory>
       5             : 
       6             : /*
       7             :  * doctest requires an implementation of type to string conversion for regular
       8             :  * use. Using double parenthesis avoids decomposition as a workaround. See also:
       9             :  * https://github.com/onqtam/doctest/blob/master/doc/markdown/stringification.md
      10             :  */
      11             : 
      12           2 : SCENARIO("polymorphic classes")
      13             : {
      14           2 :         GIVEN("one class that derives from an abstract base")
      15             :         {
      16           2 :                 auto der = std::make_shared<::derived>();
      17           1 :                 REQUIRE((der != nullptr));
      18             : 
      19           2 :                 WHEN("derived class is cast to base")
      20             :                 {
      21           2 :                         auto base = std::dynamic_pointer_cast<::base>(der);
      22             : 
      23           2 :                         THEN("the abstract base can be used")
      24             :                         {
      25           1 :                                 REQUIRE((base != nullptr));
      26           1 :                                 base->init();
      27             :                         }
      28             :                 }
      29             :         }
      30           4 : }

Generated by: LCOV version 1.13