From bc3a41d96cda7d0a4179a1c0f58e300316825481 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 26 Feb 2018 23:18:54 -0300 Subject: [PATCH] tests: Add event test --- tests/meson.build | 14 ++++++++++ tests/test-event.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/test-event.c diff --git a/tests/meson.build b/tests/meson.build index a76d0aa7..bea60760 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -12,6 +12,20 @@ test_env = [ test_cflags = '-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.source_root(), 'data')) +######### +# Event # +######### + +test_event = executable( + 'test-event', + ['test-event.c', compiled_schemas], + c_args: test_cflags, + dependencies: test_deps +) + +test('test-event', test_event, env: test_env) + + ########### # Manager # ########### diff --git a/tests/test-event.c b/tests/test-event.c new file mode 100644 index 00000000..08d908c6 --- /dev/null +++ b/tests/test-event.c @@ -0,0 +1,65 @@ +/* test-event.c + * + * Copyright © 2018 Georges Basile Stavracas Neto + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "gcal-utils.h" +#include "gcal-event.h" + +#define STUB_EVENT "BEGIN:VEVENT \n" \ + "SUMMARY:Stub event \n" \ + "UID:example@uid \n" \ + "DTSTAMP:20180714T170000Z \n" \ + "DTSTART:20180714T170000Z \n" \ + "DTEND:20180715T035959Z \n" \ + "END:VEVENT \n" + +/*********************************************************************************************************************/ + +static void +event_new (void) +{ + g_autoptr (ECalComponent) component; + g_autoptr (GcalEvent) event; + g_autoptr (ESource) source; + g_autoptr (GError) error; + + component = e_cal_component_new_from_string (STUB_EVENT); + source = e_source_new_with_uid ("stub", NULL, &error); + + g_assert_no_error (error); + + event = gcal_event_new (source, component, &error); + + g_assert_no_error (error); + g_assert_nonnull (event); +} + +/*********************************************************************************************************************/ + +gint +main (gint argc, + gchar *argv[]) +{ + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/event/new", event_new); + + return g_test_run (); +} +