LCOV - code coverage report
Current view: top level - listrev/unittest - ListStorage_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 47 47
Test Date: 2025-12-21 13:07:08 Functions: 100.0 % 6 6

            Line data    Source code
       1              : /**
       2              :  * @file ListStorage_test.cxx ListStorage class Unit Tests
       3              :  *
       4              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : 
       9              : #include "../src/ListStorage.hpp"
      10              : #include "../src/CommonIssues.hpp"
      11              : 
      12              : #define BOOST_TEST_MODULE ListStorage_test // NOLINT
      13              : 
      14              : #include "boost/test/unit_test.hpp"
      15              : 
      16              : #include <string>
      17              : #include <vector>
      18              : 
      19              : using namespace dunedaq::listrev;
      20              : 
      21              : BOOST_AUTO_TEST_SUITE(ListStorage_test)
      22              : 
      23            2 : BOOST_AUTO_TEST_CASE(BasicTests)
      24              : {
      25            1 :   ListStorage stor;
      26            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 0);
      27            1 :   BOOST_REQUIRE(!stor.has_list(0));
      28            1 : }
      29              : 
      30            2 : BOOST_AUTO_TEST_CASE(Methods)
      31              : {
      32            1 :   ListStorage stor;
      33            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 0);
      34              : 
      35            1 :   IntList firstList(1, 1, { 3, 4, 5, 6 });
      36            1 :   IntList secondList(2, 1, { 7, 8 });
      37            1 :   IntList thirdList(3, 1, { 9, 10, 11, 12, 13 });
      38            1 :   IntList anotherSecondList(2, 2, { 14, 15, 16 });
      39              : 
      40            1 :   stor.set_capacity(2);
      41            1 :   BOOST_REQUIRE_EQUAL(stor.capacity(), 2);
      42              : 
      43            1 :   stor.add_list(firstList);
      44            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 1);
      45            1 :   BOOST_REQUIRE(stor.has_list(1));
      46            1 :   auto retrieved = stor.get_list(1);
      47            1 :   BOOST_REQUIRE_EQUAL(retrieved.list_id, firstList.list_id);
      48            1 :   BOOST_REQUIRE_EQUAL(retrieved.generator_id, firstList.generator_id);
      49            1 :   BOOST_REQUIRE_EQUAL(retrieved.list.size(), firstList.list.size());
      50              : 
      51            1 :   stor.add_list(secondList);
      52            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 2);
      53            1 :   BOOST_REQUIRE(stor.has_list(1));
      54            1 :   BOOST_REQUIRE(stor.has_list(2));
      55              : 
      56            1 :   stor.add_list(thirdList);
      57            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 2);
      58            1 :   BOOST_REQUIRE(!stor.has_list(1));
      59            1 :   BOOST_REQUIRE(stor.has_list(2));
      60            1 :   BOOST_REQUIRE(stor.has_list(3));
      61              : 
      62            3 :   BOOST_REQUIRE_EXCEPTION(stor.get_list(1), ListNotFound, [&](ListNotFound) { return true; });
      63            4 :   BOOST_REQUIRE_EXCEPTION(stor.add_list(anotherSecondList), ListExists, [&](ListExists) { return true; });
      64            1 :   stor.add_list(anotherSecondList, true);
      65            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 2);
      66            1 :   BOOST_REQUIRE(!stor.has_list(1));
      67            1 :   BOOST_REQUIRE(stor.has_list(2));
      68            1 :   BOOST_REQUIRE(stor.has_list(3));
      69            1 :   retrieved = stor.get_list(2);
      70            1 :   BOOST_REQUIRE_EQUAL(retrieved.list_id, anotherSecondList.list_id);
      71            1 :   BOOST_REQUIRE_EQUAL(retrieved.generator_id, anotherSecondList.generator_id);
      72            1 :   BOOST_REQUIRE_EQUAL(retrieved.list.size(), anotherSecondList.list.size());
      73              : 
      74            1 :   stor.flush();
      75            1 :   BOOST_REQUIRE_EQUAL(stor.size(), 0);
      76            1 :   BOOST_REQUIRE(!stor.has_list(1));
      77            1 :   BOOST_REQUIRE(!stor.has_list(2));
      78            1 :   BOOST_REQUIRE(!stor.has_list(3));
      79            1 : }
      80              : 
      81              : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1