LCOV - code coverage report
Current view: top level - unit_tests/tests - test_log_buffer.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 18 100.0 %
Date: 2024-04-22 23:59:02 Functions: 8 8 100.0 %

          Line data    Source code
       1             : #include "pch.h"
       2             : 
       3             : using ::testing::ElementsAre;
       4             : 
       5           4 : TEST(logBuffer, writeSmall) {
       6           1 :         LogBuffer<10> dut;
       7           1 :         memset(dut.m_buffer, 0x55, sizeof(dut.m_buffer));
       8             : 
       9           1 :         LogLineBuffer line;
      10             : 
      11           1 :         strcpy(line.buffer, "test");
      12             : 
      13           1 :         dut.writeLine(&line);
      14             : 
      15           1 :         EXPECT_THAT(dut.m_buffer, ElementsAre(
      16             :                 't', 'e', 's', 't', '\0',       // this part got copied in
      17             :                 0x55, 0x55, 0x55, 0x55, 0x55    // rest of the buffer is untouched
      18           1 :         ));
      19           1 : }
      20             : 
      21           4 : TEST(logBuffer, writeOverflow) {
      22           1 :         LogBuffer<10> dut;
      23           1 :         memset(dut.m_buffer, 0x55, sizeof(dut.m_buffer));
      24             : 
      25           1 :         LogLineBuffer line;
      26             : 
      27           1 :         strcpy(line.buffer, "testtesttest");
      28             : 
      29           1 :         dut.writeLine(&line);
      30             : 
      31           1 :         EXPECT_THAT(dut.m_buffer, ElementsAre(
      32             :                 't', 'e', 's', 't',
      33             :                 't', 'e', 's', 't',
      34             :                 't', 0
      35           1 :         ));
      36           1 : }

Generated by: LCOV version 1.14