Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 : : * 3 : : * Copyright © 2018 Endless Mobile, Inc. 4 : : * 5 : : * This library is free software; you can redistribute it and/or 6 : : * modify it under the terms of the GNU Lesser General Public 7 : : * License as published by the Free Software Foundation; either 8 : : * version 2.1 of the License, or (at your option) any later version. 9 : : * 10 : : * This library is distributed in the hope that it will be useful, 11 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 : : * Lesser General Public License for more details. 14 : : * 15 : : * You should have received a copy of the GNU Lesser General Public 16 : : * License along with this library; if not, write to the Free Software 17 : : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 : : * 19 : : * Authors: 20 : : * - Philip Withnall <withnall@endlessm.com> 21 : : */ 22 : : 23 : : #include "config.h" 24 : : 25 : : #include <glib.h> 26 : : #include <libmogwai-tariff/period.h> 27 : : 28 : : #include "common.h" 29 : : 30 : : 31 : : void 32 : 4 : assert_periods_equal (MwtPeriod *period1, 33 : : MwtPeriod *period2) 34 : : { 35 [ - + ]: 4 : g_assert_true (MWT_IS_PERIOD (period1)); 36 [ - + ]: 4 : g_assert_true (MWT_IS_PERIOD (period2)); 37 : : 38 : 4 : GDateTime *period1_start = mwt_period_get_start (period1); 39 : 4 : GTimeZone *period1_start_tz = g_date_time_get_timezone (period1_start); 40 : 4 : GDateTime *period1_end = mwt_period_get_end (period1); 41 : 4 : GTimeZone *period1_end_tz = g_date_time_get_timezone (period1_end); 42 : 4 : GDateTime *period2_start = mwt_period_get_start (period2); 43 : 4 : GTimeZone *period2_start_tz = g_date_time_get_timezone (period2_start); 44 : 4 : GDateTime *period2_end = mwt_period_get_end (period2); 45 : 4 : GTimeZone *period2_end_tz = g_date_time_get_timezone (period2_end); 46 : : 47 [ - + ]: 4 : g_assert_true (g_date_time_equal (period1_start, period2_start)); 48 [ - + ]: 4 : g_assert_cmpstr (g_time_zone_get_identifier (period1_start_tz), ==, 49 : : g_time_zone_get_identifier (period2_start_tz)); 50 [ - + ]: 4 : g_assert_true (g_date_time_equal (period1_end, period2_end)); 51 [ - + ]: 4 : g_assert_cmpstr (g_time_zone_get_identifier (period1_end_tz), ==, 52 : : g_time_zone_get_identifier (period2_end_tz)); 53 : : 54 [ - + ]: 4 : g_assert_cmpint (mwt_period_get_repeat_type (period1), ==, 55 : : mwt_period_get_repeat_type (period2)); 56 [ - + ]: 4 : g_assert_cmpuint (mwt_period_get_repeat_period (period1), ==, 57 : : mwt_period_get_repeat_period (period2)); 58 : : 59 [ - + ]: 4 : g_assert_cmpuint (mwt_period_get_capacity_limit (period1), ==, 60 : : mwt_period_get_capacity_limit (period2)); 61 : 4 : }