LCOV - code coverage report
Current view: top level - tests - coordinate.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 25 25 100.0 %
Date: 2024-05-11 21:41:31 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 14 57.1 %

           Branch data     Line data    Source code
       1                 :            : #undef G_DISABLE_ASSERT
       2                 :            : 
       3                 :            : #include <gtk/gtk.h>
       4                 :            : #include <shumate/shumate.h>
       5                 :            : 
       6                 :            : #define ACCEPTABLE_EPSILON 0.0000000000001
       7                 :            : 
       8                 :            : static void
       9                 :          3 : test_coordinate_convert (void)
      10                 :            : {
      11                 :          3 :   ShumateMapSourceRegistry *registry;
      12                 :          3 :   ShumateMapSource *source;
      13                 :          3 :   double latitude = -73.75f;
      14                 :          3 :   double longitude = 45.466f;
      15                 :          3 :   double zoom_level;
      16                 :            : 
      17                 :          3 :   registry = shumate_map_source_registry_new_with_defaults ();
      18                 :            : 
      19         [ -  + ]:          3 :   g_assert_nonnull (registry);
      20                 :            : 
      21                 :          3 :   source = shumate_map_source_registry_get_by_id (registry, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
      22                 :            : 
      23         [ -  + ]:          3 :   g_assert_nonnull (source);
      24                 :            :   
      25                 :          3 :   for (zoom_level = shumate_map_source_get_min_zoom_level (source);
      26         [ +  + ]:        114 :        zoom_level <= shumate_map_source_get_max_zoom_level (source);
      27                 :        111 :        zoom_level += 0.5)
      28                 :            :     {
      29                 :        111 :       double x;
      30                 :        111 :       double y;
      31                 :            : 
      32                 :        111 :       x = shumate_map_source_get_x (source, zoom_level, longitude);
      33   [ -  +  -  + ]:        111 :       g_assert_cmpfloat_with_epsilon (shumate_map_source_get_longitude (source, zoom_level, x), longitude, ACCEPTABLE_EPSILON);
      34                 :            : 
      35                 :        111 :       y = shumate_map_source_get_y (source, zoom_level, latitude);
      36   [ -  +  -  + ]:        111 :       g_assert_cmpfloat_with_epsilon (shumate_map_source_get_latitude (source, zoom_level, y), latitude, ACCEPTABLE_EPSILON);
      37                 :            :     }
      38                 :            : 
      39                 :          3 :   g_object_unref (registry);
      40                 :          3 : }
      41                 :            : 
      42                 :            : int
      43                 :          3 : main (int argc, char *argv[])
      44                 :            : {
      45                 :          3 :   g_test_init (&argc, &argv, NULL);
      46                 :            : 
      47                 :          3 :   g_test_add_func ("/coordinate/convert", test_coordinate_convert);
      48                 :            : 
      49                 :          3 :   return g_test_run ();
      50                 :            : }

Generated by: LCOV version 1.14