LCOV - code coverage report
Current view: top level - tests/config - MapConfigFileHandlerTests.cpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 60 60 100.0 %
Date: 2022-10-04 09:48:07 Functions: 16 16 100.0 %
Branches: 132 562 23.5 %

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2018-2021 Intel Corporation
       4                 :            : //
       5                 :            : // SPDX-License-Identifier: MIT
       6                 :            : //
       7                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       8                 :            : 
       9                 :            : #include <ad/map/config/MapConfigFileHandler.hpp>
      10                 :            : #include <ad/map/test_support/NoLogTestMacros.hpp>
      11                 :            : 
      12                 :            : #include <gtest/gtest.h>
      13                 :            : 
      14                 :          2 : TEST(MapConfigFileHandler, readValidConfig)
      15                 :            : {
      16                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      17   [ +  -  +  -  :          1 :   ASSERT_STREQ("", configHandler.configFileName().c_str());
          -  +  -  -  -  
                -  -  - ]
      18   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/TPK.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      19   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
      20                 :            : 
      21                 :            :   // the configFileName is a fully qualified path, check that it is correctly returned
      22         [ +  - ]:          1 :   auto const &actual = configHandler.configFileName();
      23         [ +  - ]:          1 :   std::string const expected("TPK.adm.txt");
      24   [ +  -  -  +  :          1 :   ASSERT_GT(actual.size(), expected.size());
          -  -  -  -  -  
                      - ]
      25                 :          1 :   auto expectedPos = actual.size() - expected.size();
      26   [ +  -  -  +  :          1 :   ASSERT_EQ(actual.find(expected), expectedPos);
          -  -  -  -  -  
                      - ]
      27                 :            : 
      28   [ +  -  +  -  :          1 :   EXPECT_EQ(6u, configHandler.pointsOfInterest().size());
          -  +  -  -  -  
                -  -  - ]
      29                 :            : 
      30   [ +  -  +  -  :          2 :   ASSERT_FALSE_NO_LOG(configHandler.readConfig("test_files/non_existing.txt"));
          +  -  +  -  +  
          -  -  +  -  -  
          -  -  -  -  -  
                -  +  - ]
      31                 :            :   // reading a second time
      32   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/TPK.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      33                 :            : }
      34                 :            : 
      35                 :          2 : TEST(MapConfigFileHandler, non_existing)
      36                 :            : {
      37                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      38   [ +  -  +  -  :          2 :   ASSERT_FALSE_NO_LOG(configHandler.readConfig("test_files/non_existing.txt"));
          +  -  +  -  +  
          -  -  +  -  -  
          -  -  -  -  -  
                -  +  - ]
      39   [ +  -  -  +  :          1 :   ASSERT_FALSE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
      40   [ +  -  +  -  :          1 :   ASSERT_STREQ("", configHandler.configFileName().c_str());
          -  +  -  -  -  
                -  -  - ]
      41   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/TPK.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      42   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
      43                 :            : }
      44                 :            : 
      45                 :          2 : TEST(MapConfigFileHandler, map_config_invalid_map_location)
      46                 :            : {
      47                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      48   [ +  -  +  -  :          2 :   ASSERT_FALSE_NO_LOG(configHandler.readConfig("test_files/map_config_invalid_map_location.txt"));
          +  -  +  -  +  
          -  -  +  -  -  
          -  -  -  -  -  
                -  +  - ]
      49                 :            : }
      50                 :            : 
      51                 :          2 : TEST(MapConfigFileHandler, map_config_map_location_out_of_tree)
      52                 :            : {
      53                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      54   [ +  -  +  -  :          2 :   ASSERT_FALSE_NO_LOG(configHandler.readConfig("test_files/map_config_map_location_out_of_tree.txt"));
          +  -  +  -  +  
          -  -  +  -  -  
          -  -  -  -  -  
                -  +  - ]
      55                 :            : }
      56                 :            : 
      57                 :          2 : TEST(MapConfigFileHandler, invalid_default_enu_reference_config)
      58                 :            : {
      59                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      60   [ +  -  +  -  :          2 :   ASSERT_FALSE_NO_LOG(configHandler.readConfig("test_files/map_config_invalid_default_enu_reference.txt"));
          +  -  +  -  +  
          -  -  +  -  -  
          -  -  -  -  -  
                -  +  - ]
      61   [ +  -  -  +  :          1 :   EXPECT_FALSE(configHandler.defaultEnuReferenceAvailable());
          -  -  -  -  -  
                -  -  - ]
      62                 :            : }
      63                 :            : 
      64                 :          2 : TEST(MapConfigFileHandler, valid_default_enu_reference_config)
      65                 :            : {
      66                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      67   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/TPK_PFZ.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      68   [ +  -  -  +  :          1 :   EXPECT_TRUE(configHandler.defaultEnuReferenceAvailable());
          -  -  -  -  -  
                -  -  - ]
      69   [ +  -  +  -  :          1 :   EXPECT_EQ(ad::map::point::Latitude(49.0080515), configHandler.defaultEnuReference().latitude);
          -  +  -  -  -  
                -  -  - ]
      70   [ +  -  +  -  :          1 :   EXPECT_EQ(ad::map::point::Longitude(8.442078), configHandler.defaultEnuReference().longitude);
          -  +  -  -  -  
                -  -  - ]
      71   [ +  -  +  -  :          1 :   EXPECT_EQ(ad::map::point::Altitude(0.), configHandler.defaultEnuReference().altitude);
          -  +  -  -  -  
                -  -  - ]
      72                 :            : }
      73                 :            : 
      74                 :          2 : TEST(MapConfigFileHandler, reset)
      75                 :            : {
      76                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      77   [ +  -  +  -  :          1 :   ASSERT_STREQ("", configHandler.configFileName().c_str());
          -  +  -  -  -  
                -  -  - ]
      78   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/TPK.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      79   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
      80                 :            : 
      81         [ +  - ]:          1 :   configHandler.reset();
      82   [ +  -  -  +  :          1 :   ASSERT_FALSE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
      83   [ +  -  +  -  :          1 :   ASSERT_EQ(configHandler.adMapEntry().filename, "");
          -  +  -  -  -  
                -  -  - ]
      84   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.configFileName().empty());
          -  -  -  -  -  
                -  -  - ]
      85   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.pointsOfInterest().empty());
          -  -  -  -  -  
                -  -  - ]
      86                 :            : }
      87                 :            : 
      88                 :          2 : TEST(MapConfigFileHandler, bad_branch)
      89                 :            : {
      90                 :          1 :   ad::map::config::MapConfigFileHandler configHandler{};
      91   [ +  -  +  -  :          1 :   ASSERT_STREQ("", configHandler.configFileName().c_str());
          -  +  -  -  -  
                -  -  - ]
      92   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/non_existent.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      93   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/poi.bad1.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      94   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/poi.bad2.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      95   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/poi.bad3.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      96   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/poi.bad4.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      97   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/poi.bad5.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
      98                 :            : 
      99   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/enu.bad1.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     100   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/enu.bad2.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     101   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/enu.bad3.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     102                 :            : 
     103   [ +  -  +  -  :          1 :   ASSERT_FALSE(configHandler.readConfig("test_files/bad/opendrive.overlap.bad.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     104                 :            : }

Generated by: LCOV version 1.14