/* datasource-test.c generated by valac 0.43.6.10-d9d11, the Vala compiler
 * generated from datasource-test.vala, do not modify */

/* datamodel-test.vala
 *
 * Copyright © 2012 Canonical Ltd.
 *             By Siegfried-A. Gevatter <siegfried.gevatter@collabora.co.uk>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 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 Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "zeitgeist-datamodel.h"

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

gint _vala_main (gchar** argv,
                 gint argv_length1);
void create_empty_test (void);
static void _create_empty_test_gtest_func (void);
void create_full_test (void);
static void _create_full_test_gtest_func (void);
void to_from_variant_test (void);
static void _to_from_variant_test_gtest_func (void);
static void _g_object_unref0_ (gpointer var);

static void
_create_empty_test_gtest_func (void)
{
#line 28 "datasource-test.vala"
	create_empty_test ();
#line 53 "datasource-test.c"
}

static void
_create_full_test_gtest_func (void)
{
#line 29 "datasource-test.vala"
	create_full_test ();
#line 61 "datasource-test.c"
}

static void
_to_from_variant_test_gtest_func (void)
{
#line 30 "datasource-test.vala"
	to_from_variant_test ();
#line 69 "datasource-test.c"
}

gint
_vala_main (gchar** argv,
            gint argv_length1)
{
	gint result = 0;
#line 26 "datasource-test.vala"
	g_test_init ((gint*) (&argv_length1), &argv, NULL);
#line 28 "datasource-test.vala"
	g_test_add_func ("/Datasource/CreateEmpty", _create_empty_test_gtest_func);
#line 29 "datasource-test.vala"
	g_test_add_func ("/Datasource/CreateFull", _create_full_test_gtest_func);
#line 30 "datasource-test.vala"
	g_test_add_func ("/Datasource/ToFromVariant", _to_from_variant_test_gtest_func);
#line 32 "datasource-test.vala"
	result = g_test_run ();
#line 32 "datasource-test.vala"
	return result;
#line 89 "datasource-test.c"
}

int
main (int argc,
      char ** argv)
{
#line 24 "datasource-test.vala"
	return _vala_main (argv, argc);
#line 98 "datasource-test.c"
}

void
create_empty_test (void)
{
	ZeitgeistDataSource* src = NULL;
	ZeitgeistDataSource* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GPtrArray* _tmp7_;
	GPtrArray* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	gint64 _tmp11_;
	gint64 _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
#line 37 "datasource-test.vala"
	_tmp0_ = zeitgeist_data_source_new ();
#line 37 "datasource-test.vala"
	src = _tmp0_;
#line 38 "datasource-test.vala"
	_tmp1_ = zeitgeist_data_source_get_unique_id (src);
#line 38 "datasource-test.vala"
	_tmp2_ = _tmp1_;
#line 38 "datasource-test.vala"
	g_assert_cmpstr (_tmp2_, ==, NULL);
#line 39 "datasource-test.vala"
	_tmp3_ = zeitgeist_data_source_get_name (src);
#line 39 "datasource-test.vala"
	_tmp4_ = _tmp3_;
#line 39 "datasource-test.vala"
	g_assert_cmpstr (_tmp4_, ==, NULL);
#line 40 "datasource-test.vala"
	_tmp5_ = zeitgeist_data_source_get_description (src);
#line 40 "datasource-test.vala"
	_tmp6_ = _tmp5_;
#line 40 "datasource-test.vala"
	g_assert_cmpstr (_tmp6_, ==, NULL);
#line 41 "datasource-test.vala"
	_tmp7_ = zeitgeist_data_source_get_event_templates (src);
#line 41 "datasource-test.vala"
	_tmp8_ = _tmp7_;
#line 41 "datasource-test.vala"
	_vala_assert (_tmp8_ == NULL, "src.event_templates == null");
#line 42 "datasource-test.vala"
	_tmp9_ = zeitgeist_data_source_get_running (src);
#line 42 "datasource-test.vala"
	_tmp10_ = _tmp9_;
#line 42 "datasource-test.vala"
	_vala_assert (_tmp10_ == FALSE, "src.running == false");
#line 43 "datasource-test.vala"
	_tmp11_ = zeitgeist_data_source_get_timestamp (src);
#line 43 "datasource-test.vala"
	_tmp12_ = _tmp11_;
#line 43 "datasource-test.vala"
	_vala_assert (_tmp12_ == ((gint64) 0), "src.timestamp == 0");
#line 44 "datasource-test.vala"
	_tmp13_ = zeitgeist_data_source_get_enabled (src);
#line 44 "datasource-test.vala"
	_tmp14_ = _tmp13_;
#line 44 "datasource-test.vala"
	_vala_assert (_tmp14_ == TRUE, "src.enabled == true");
#line 35 "datasource-test.vala"
	_g_object_unref0 (src);
#line 168 "datasource-test.c"
}

static void
_g_object_unref0_ (gpointer var)
{
#line 67 "datasource-test.vala"
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
#line 176 "datasource-test.c"
}

void
create_full_test (void)
{
	ZeitgeistDataSource* src = NULL;
	ZeitgeistDataSource* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GPtrArray* _tmp7_;
	GPtrArray* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	gint64 _tmp11_;
	gint64 _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	gint64 now = 0LL;
	gboolean _tmp15_;
	gboolean _tmp16_;
	gint64 _tmp17_;
	gint64 _tmp18_;
	gboolean _tmp19_;
	gboolean _tmp20_;
	GPtrArray* event_templates = NULL;
	GPtrArray* _tmp21_;
	ZeitgeistEvent* _tmp22_;
	GPtrArray* _tmp23_;
	GPtrArray* _tmp24_;
#line 49 "datasource-test.vala"
	_tmp0_ = zeitgeist_data_source_new_full ("my-id", "my-name", "my-desc", NULL);
#line 49 "datasource-test.vala"
	src = _tmp0_;
#line 51 "datasource-test.vala"
	_tmp1_ = zeitgeist_data_source_get_unique_id (src);
#line 51 "datasource-test.vala"
	_tmp2_ = _tmp1_;
#line 51 "datasource-test.vala"
	g_assert_cmpstr (_tmp2_, ==, "my-id");
#line 52 "datasource-test.vala"
	_tmp3_ = zeitgeist_data_source_get_name (src);
#line 52 "datasource-test.vala"
	_tmp4_ = _tmp3_;
#line 52 "datasource-test.vala"
	g_assert_cmpstr (_tmp4_, ==, "my-name");
#line 53 "datasource-test.vala"
	_tmp5_ = zeitgeist_data_source_get_description (src);
#line 53 "datasource-test.vala"
	_tmp6_ = _tmp5_;
#line 53 "datasource-test.vala"
	g_assert_cmpstr (_tmp6_, ==, "my-desc");
#line 54 "datasource-test.vala"
	_tmp7_ = zeitgeist_data_source_get_event_templates (src);
#line 54 "datasource-test.vala"
	_tmp8_ = _tmp7_;
#line 54 "datasource-test.vala"
	_vala_assert (_tmp8_ == NULL, "src.event_templates == null");
#line 55 "datasource-test.vala"
	_tmp9_ = zeitgeist_data_source_get_running (src);
#line 55 "datasource-test.vala"
	_tmp10_ = _tmp9_;
#line 55 "datasource-test.vala"
	_vala_assert (_tmp10_ == FALSE, "src.running == false");
#line 56 "datasource-test.vala"
	_tmp11_ = zeitgeist_data_source_get_timestamp (src);
#line 56 "datasource-test.vala"
	_tmp12_ = _tmp11_;
#line 56 "datasource-test.vala"
	_vala_assert (_tmp12_ == ((gint64) 0), "src.timestamp ==  0");
#line 57 "datasource-test.vala"
	_tmp13_ = zeitgeist_data_source_get_enabled (src);
#line 57 "datasource-test.vala"
	_tmp14_ = _tmp13_;
#line 57 "datasource-test.vala"
	_vala_assert (_tmp14_ == TRUE, "src.enabled == true");
#line 59 "datasource-test.vala"
	now = zeitgeist_timestamp_from_now ();
#line 60 "datasource-test.vala"
	zeitgeist_data_source_set_running (src, TRUE);
#line 61 "datasource-test.vala"
	zeitgeist_data_source_set_timestamp (src, now);
#line 62 "datasource-test.vala"
	zeitgeist_data_source_set_enabled (src, FALSE);
#line 63 "datasource-test.vala"
	_tmp15_ = zeitgeist_data_source_get_running (src);
#line 63 "datasource-test.vala"
	_tmp16_ = _tmp15_;
#line 63 "datasource-test.vala"
	_vala_assert (_tmp16_ == TRUE, "src.running == true");
#line 64 "datasource-test.vala"
	_tmp17_ = zeitgeist_data_source_get_timestamp (src);
#line 64 "datasource-test.vala"
	_tmp18_ = _tmp17_;
#line 64 "datasource-test.vala"
	_vala_assert (_tmp18_ == now, "src.timestamp == now");
#line 65 "datasource-test.vala"
	_tmp19_ = zeitgeist_data_source_get_enabled (src);
#line 65 "datasource-test.vala"
	_tmp20_ = _tmp19_;
#line 65 "datasource-test.vala"
	_vala_assert (_tmp20_ == FALSE, "src.enabled == false");
#line 67 "datasource-test.vala"
	_tmp21_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
#line 67 "datasource-test.vala"
	event_templates = _tmp21_;
#line 68 "datasource-test.vala"
	_tmp22_ = zeitgeist_event_new ();
#line 68 "datasource-test.vala"
	g_ptr_array_add (event_templates, _tmp22_);
#line 69 "datasource-test.vala"
	zeitgeist_data_source_set_event_templates (src, event_templates);
#line 70 "datasource-test.vala"
	_tmp23_ = zeitgeist_data_source_get_event_templates (src);
#line 70 "datasource-test.vala"
	_tmp24_ = _tmp23_;
#line 70 "datasource-test.vala"
	_vala_assert (_tmp24_ == event_templates, "src.event_templates == event_templates");
#line 47 "datasource-test.vala"
	_g_ptr_array_unref0 (event_templates);
#line 47 "datasource-test.vala"
	_g_object_unref0 (src);
#line 302 "datasource-test.c"
}

static gpointer
_g_ptr_array_ref0 (gpointer self)
{
#line 92 "datasource-test.vala"
	return self ? g_ptr_array_ref (self) : NULL;
#line 310 "datasource-test.c"
}

static gint
g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
#line 5099 "glib-2.0.vapi"
	g_return_val_if_fail (self != NULL, 0);
#line 5099 "glib-2.0.vapi"
	result = (gint) self->len;
#line 5099 "glib-2.0.vapi"
	return result;
#line 323 "datasource-test.c"
}

static void
g_ptr_array_set_length (GPtrArray* self,
                        gint value)
{
#line 5100 "glib-2.0.vapi"
	g_return_if_fail (self != NULL);
#line 5100 "glib-2.0.vapi"
	g_ptr_array_set_size (self, value);
#line 334 "datasource-test.c"
}

void
to_from_variant_test (void)
{
	ZeitgeistDataSource* orig = NULL;
	ZeitgeistDataSource* _tmp0_;
	gint64 now = 0LL;
	GPtrArray* event_templates = NULL;
	GPtrArray* _tmp1_;
	GPtrArray* _tmp2_;
	ZeitgeistEvent* _tmp3_;
	GPtrArray* _tmp4_;
	ZeitgeistDataSource* src = NULL;
	GVariant* _tmp5_;
	GVariant* _tmp6_;
	ZeitgeistDataSource* _tmp7_;
	ZeitgeistDataSource* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	GPtrArray* _tmp15_;
	GPtrArray* _tmp16_;
	gboolean _tmp17_;
	gboolean _tmp18_;
	gint64 _tmp19_;
	gint64 _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	GPtrArray* _tmp23_;
	GPtrArray* _tmp24_;
	GPtrArray* _tmp25_;
	GPtrArray* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	GPtrArray* _tmp29_;
	gconstpointer _tmp30_;
	GError* _inner_error0_ = NULL;
#line 75 "datasource-test.vala"
	_tmp0_ = zeitgeist_data_source_new_full ("my-id", "my-name", "my-desc", NULL);
#line 75 "datasource-test.vala"
	orig = _tmp0_;
#line 76 "datasource-test.vala"
	now = zeitgeist_timestamp_from_now ();
#line 77 "datasource-test.vala"
	zeitgeist_data_source_set_timestamp (orig, now);
#line 79 "datasource-test.vala"
	_tmp1_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
#line 79 "datasource-test.vala"
	event_templates = _tmp1_;
#line 80 "datasource-test.vala"
	_tmp2_ = event_templates;
#line 80 "datasource-test.vala"
	_tmp3_ = zeitgeist_event_new ();
#line 80 "datasource-test.vala"
	g_ptr_array_add (_tmp2_, _tmp3_);
#line 81 "datasource-test.vala"
	_tmp4_ = event_templates;
#line 81 "datasource-test.vala"
	zeitgeist_data_source_set_event_templates (orig, _tmp4_);
#line 83 "datasource-test.vala"
	_tmp5_ = zeitgeist_data_source_to_variant (orig);
#line 83 "datasource-test.vala"
	_tmp6_ = _tmp5_;
#line 83 "datasource-test.vala"
	_tmp7_ = zeitgeist_data_source_new_from_variant (_tmp6_, FALSE, &_inner_error0_);
#line 83 "datasource-test.vala"
	_tmp8_ = _tmp7_;
#line 83 "datasource-test.vala"
	_g_variant_unref0 (_tmp6_);
#line 83 "datasource-test.vala"
	src = _tmp8_;
#line 83 "datasource-test.vala"
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 83 "datasource-test.vala"
		_g_ptr_array_unref0 (event_templates);
#line 83 "datasource-test.vala"
		_g_object_unref0 (orig);
#line 83 "datasource-test.vala"
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
#line 83 "datasource-test.vala"
		g_clear_error (&_inner_error0_);
#line 83 "datasource-test.vala"
		return;
#line 422 "datasource-test.c"
	}
#line 84 "datasource-test.vala"
	_tmp9_ = zeitgeist_data_source_get_unique_id (src);
#line 84 "datasource-test.vala"
	_tmp10_ = _tmp9_;
#line 84 "datasource-test.vala"
	g_assert_cmpstr (_tmp10_, ==, "my-id");
#line 85 "datasource-test.vala"
	_tmp11_ = zeitgeist_data_source_get_name (src);
#line 85 "datasource-test.vala"
	_tmp12_ = _tmp11_;
#line 85 "datasource-test.vala"
	g_assert_cmpstr (_tmp12_, ==, "my-name");
#line 86 "datasource-test.vala"
	_tmp13_ = zeitgeist_data_source_get_description (src);
#line 86 "datasource-test.vala"
	_tmp14_ = _tmp13_;
#line 86 "datasource-test.vala"
	g_assert_cmpstr (_tmp14_, ==, "my-desc");
#line 87 "datasource-test.vala"
	_tmp15_ = zeitgeist_data_source_get_event_templates (src);
#line 87 "datasource-test.vala"
	_tmp16_ = _tmp15_;
#line 87 "datasource-test.vala"
	_vala_assert (_tmp16_ != NULL, "src.event_templates != null");
#line 88 "datasource-test.vala"
	_tmp17_ = zeitgeist_data_source_get_running (src);
#line 88 "datasource-test.vala"
	_tmp18_ = _tmp17_;
#line 88 "datasource-test.vala"
	_vala_assert (_tmp18_ == FALSE, "src.running == false");
#line 89 "datasource-test.vala"
	_tmp19_ = zeitgeist_data_source_get_timestamp (src);
#line 89 "datasource-test.vala"
	_tmp20_ = _tmp19_;
#line 89 "datasource-test.vala"
	_vala_assert (_tmp20_ == now, "src.timestamp == now");
#line 90 "datasource-test.vala"
	_tmp21_ = zeitgeist_data_source_get_enabled (src);
#line 90 "datasource-test.vala"
	_tmp22_ = _tmp21_;
#line 90 "datasource-test.vala"
	_vala_assert (_tmp22_ == TRUE, "src.enabled == true");
#line 92 "datasource-test.vala"
	_tmp23_ = zeitgeist_data_source_get_event_templates (src);
#line 92 "datasource-test.vala"
	_tmp24_ = _tmp23_;
#line 92 "datasource-test.vala"
	_tmp25_ = _g_ptr_array_ref0 (_tmp24_);
#line 92 "datasource-test.vala"
	_g_ptr_array_unref0 (event_templates);
#line 92 "datasource-test.vala"
	event_templates = _tmp25_;
#line 93 "datasource-test.vala"
	_tmp26_ = event_templates;
#line 93 "datasource-test.vala"
	_tmp27_ = g_ptr_array_get_length (_tmp26_);
#line 93 "datasource-test.vala"
	_tmp28_ = _tmp27_;
#line 93 "datasource-test.vala"
	g_assert_cmpint (_tmp28_, ==, 1);
#line 94 "datasource-test.vala"
	_tmp29_ = event_templates;
#line 94 "datasource-test.vala"
	_tmp30_ = g_ptr_array_index (_tmp29_, (guint) 0);
#line 94 "datasource-test.vala"
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE ((ZeitgeistEvent*) _tmp30_, ZEITGEIST_TYPE_EVENT), "event_templates.get (0) is Event");
#line 73 "datasource-test.vala"
	_g_object_unref0 (src);
#line 73 "datasource-test.vala"
	_g_ptr_array_unref0 (event_templates);
#line 73 "datasource-test.vala"
	_g_object_unref0 (orig);
#line 496 "datasource-test.c"
}

