LCOV - code coverage report
Current view: top level - firmware/libfirmware/util/test - test_cyclic_buffer.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 20 100.0 %
Date: 2024-04-25 02:23:43 Functions: 8 8 100.0 %

          Line data    Source code
       1             : #include <gtest/gtest.h>
       2             : 
       3             : #include "cyclic_buffer.h"
       4             : #include "rusefi/true_false.h"
       5             : 
       6           4 : TEST(util, cyclicBufferContains) {
       7           1 :         cyclic_buffer<int> sb;
       8           1 :         sb.add(10);
       9           1 :         ASSERT_EQ(TRUE, sb.contains(10));
      10           1 :         ASSERT_EQ(FALSE, sb.contains(11));
      11             : }
      12             : 
      13           4 : TEST(util, cyclicBuffer) {
      14           1 :         cyclic_buffer<int> sb;
      15             : 
      16             :         {
      17           1 :                 sb.add(10);
      18             : 
      19           1 :                 ASSERT_EQ(10, sb.sum(3));
      20             : 
      21           1 :                 sb.add(2);
      22           1 :                 ASSERT_EQ(12, sb.sum(2));
      23             :         }
      24             :         {
      25           1 :                 sb.clear();
      26             : 
      27           1 :                 sb.add(1);
      28           1 :                 sb.add(2);
      29           1 :                 sb.add(3);
      30           1 :                 sb.add(4);
      31             : 
      32           1 :                 ASSERT_EQ(4, sb.maxValue(3));
      33           1 :                 ASSERT_EQ(4, sb.maxValue(113));
      34           1 :                 ASSERT_EQ( 2,  sb.minValue(3)) << "minValue(3)";
      35           1 :                 ASSERT_EQ(1, sb.minValue(113));
      36             :         }
      37             : }

Generated by: LCOV version 1.14