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

          Line data    Source code
       1             : // Copyright 2024 Accenture.
       2             : 
       3             : #include "estd/tuple.h"
       4             : 
       5             : #include <platform/estdint.h>
       6             : 
       7             : #include <gtest/gtest.h>
       8             : 
       9             : using namespace ::testing;
      10             : 
      11             : //[EXAMPLE_GET_CONSTRAINT_START]
      12             : 
      13           3 : TEST(tuple, get)
      14             : {
      15           1 :     auto const t = std::make_tuple(uint8_t(5), uint16_t(9));
      16             : 
      17           1 :     EXPECT_EQ(5U, ::estd::get<uint8_t>(t));
      18           1 :     EXPECT_EQ(9U, ::estd::get<uint16_t>(t));
      19           1 : }
      20             : 
      21             : //[EXAMPLE_GET_CONSTRAINT_END]
      22             : 
      23             : struct Double
      24             : {
      25             :     template<typename T>
      26             :     void operator()(T& v)
      27             :     {
      28             :         v = v * 2;
      29             :     }
      30             : };
      31             : 
      32             : struct SumUp
      33             : {
      34             :     size_t value = 0;
      35             : 
      36             :     template<typename T>
      37           2 :     void operator()(T v)
      38             :     {
      39           2 :         value += v;
      40             :     }
      41             : };
      42             : 
      43             : //[EXAMPLE_FOR_EACH_CONSTRAINT_START]
      44             : 
      45           3 : TEST(tuple, for_each)
      46             : {
      47           1 :     auto const t = std::make_tuple(uint8_t(5), uint16_t(10));
      48           1 :     SumUp sum;
      49           1 :     ::estd::for_each(t, sum);
      50           1 :     EXPECT_EQ(15U, sum.value);
      51           1 : }
      52             : 
      53             : //[EXAMPLE_FOR_EACH_CONSTRAINT_END]

Generated by: LCOV version 1.14