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

          Line data    Source code
       1             : // Copyright 2024 Accenture.
       2             : 
       3             : #include <estd/array.h>
       4             : 
       5             : #include <gtest/gtest.h>
       6             : 
       7             : // EXAMPLE_START array
       8           1 : int sum(estd::array<int, 5> const& a)
       9             : {
      10           1 :     int result = 0;
      11           6 :     for (size_t i = 0; i < a.size(); ++i)
      12             :     {
      13           5 :         result += a[i];
      14             :     }
      15           1 :     return result;
      16             : }
      17             : 
      18             : // EXAMPLE_END array
      19             : 
      20           3 : TEST(ArrayExample, sum)
      21             : {
      22             :     // EXAMPLE_START array_init
      23           1 :     estd::array<int, 5> a = {1, 2, 3, 4, 5};
      24             : 
      25           1 :     int const sum_of_5 = sum(a);
      26             :     // EXAMPLE_END array_init
      27           1 :     EXPECT_EQ(15, sum_of_5);
      28           1 : }

Generated by: LCOV version 1.14