LCOV - code coverage report
Current view: top level - estd/examples - typed_mem.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2025-01-20 13:53:09 Functions: 3 4 75.0 %

          Line data    Source code
       1             : // Copyright 2024 Accenture.
       2             : 
       3             : #include "estd/typed_mem.h"
       4             : 
       5             : #include "estd/slice.h"
       6             : 
       7             : #include <gmock/gmock.h>
       8             : 
       9             : #include <array>
      10             : 
      11             : namespace
      12             : {
      13             : class ILifecycleSystem
      14             : {};
      15             : 
      16             : class LifecycleManager
      17             : {
      18             : public:
      19             :     void addComponent(char const* name, ILifecycleSystem& system, size_t runlevel){};
      20             : } lifecycleManager;
      21             : 
      22             : // Some classes just for demonstration purposes.
      23             : class StaticBsp
      24             : {
      25             : } staticBsp;
      26             : 
      27             : class CanSystem : public ILifecycleSystem
      28             : {
      29             : public:
      30           1 :     CanSystem(uint8_t taskContext, StaticBsp& staticBsp) {}
      31             : };
      32             : 
      33             : constexpr uint8_t TASK_CAN{1};
      34             : 
      35             : // [EXAMPLE_BEGIN:typed_mem_lifecycle]
      36             : 
      37             : // Create the memory for a CanSystem.
      38             : estd::typed_mem<CanSystem> canSystem;
      39             : 
      40           1 : void initLifecycle()
      41             : {
      42             :     // Construct CanSystem and add it to lifecycleManager at runlevel 1.
      43           1 :     lifecycleManager.addComponent("can", canSystem.emplace(TASK_CAN, staticBsp), 1);
      44           1 : }
      45             : 
      46             : // [EXAMPLE_END:typed_mem_lifecycle]
      47             : 
      48             : } // namespace
      49             : 
      50           3 : TEST(Typed_mem, run_examples) { initLifecycle(); }

Generated by: LCOV version 1.14