GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 25 / 0 / 25
Functions: 100.0% 2 / 0 / 2
Branches: 57.1% 8 / 0 / 14

tests/coordinate.c
Line Branch Exec Source
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 2 test_coordinate_convert (void)
10 {
11 2 ShumateMapSourceRegistry *registry;
12 2 ShumateMapSource *source;
13 2 double latitude = -73.75f;
14 2 double longitude = 45.466f;
15 2 double zoom_level;
16
17 2 registry = shumate_map_source_registry_new_with_defaults ();
18
19
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
2 g_assert_nonnull (registry);
20
21 2 source = shumate_map_source_registry_get_by_id (registry, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
22
23
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
2 g_assert_nonnull (source);
24
25 2 for (zoom_level = shumate_map_source_get_min_zoom_level (source);
26
2/2
✓ Branch 26 → 10 taken 74 times.
✓ Branch 26 → 27 taken 2 times.
76 zoom_level <= shumate_map_source_get_max_zoom_level (source);
27 74 zoom_level += 0.5)
28 {
29 74 double x;
30 74 double y;
31
32 74 x = shumate_map_source_get_x (source, zoom_level, longitude);
33
2/4
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 74 times.
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 74 times.
74 g_assert_cmpfloat_with_epsilon (shumate_map_source_get_longitude (source, zoom_level, x), longitude, ACCEPTABLE_EPSILON);
34
35 74 y = shumate_map_source_get_y (source, zoom_level, latitude);
36
2/4
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 74 times.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 74 times.
74 g_assert_cmpfloat_with_epsilon (shumate_map_source_get_latitude (source, zoom_level, y), latitude, ACCEPTABLE_EPSILON);
37 }
38
39 2 g_object_unref (registry);
40 2 }
41
42 int
43 2 main (int argc, char *argv[])
44 {
45 2 g_test_init (&argc, &argv, NULL);
46
47 2 g_test_add_func ("/coordinate/convert", test_coordinate_convert);
48
49 2 return g_test_run ();
50 }
51