/* datamodel-test.c generated by valac 0.20.1, the Vala compiler
 * generated from datamodel-test.vala, do not modify */

/* datamodel-test.vala
 *
 * Copyright © 2012 Canonical Ltd.
 *             By Siegfried-A. Gevatter <siegfried.gevatter@collabora.co.uk>
 *             By Seif Lotfy <seif@lotfy.com>
 *
 * 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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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 _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);



gint _vala_main (gchar** argv, int argv_length1);
void matches_template_anything_test (void);
static void _matches_template_anything_test_gtest_func (void);
void foreach_test (void);
static void _foreach_test_gtest_func (void);
ZeitgeistSubject* create_subject (void);
ZeitgeistEvent* create_event (void);
static void _g_object_unref0_ (gpointer var);


static void _matches_template_anything_test_gtest_func (void) {
#line 29 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	matches_template_anything_test ();
#line 51 "datamodel-test.c"
}


static void _foreach_test_gtest_func (void) {
#line 30 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	foreach_test ();
#line 58 "datamodel-test.c"
}


gint _vala_main (gchar** argv, int argv_length1) {
	gint result = 0;
	gint _tmp0_ = 0;
#line 27 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	g_test_init (&argv_length1, &argv, NULL);
#line 29 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	g_test_add_func ("/Datamodel/MatchesTemplate/anything", _matches_template_anything_test_gtest_func);
#line 30 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	g_test_add_func ("/Datamodel/MatchesTemplate/foreach", _foreach_test_gtest_func);
#line 32 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp0_ = g_test_run ();
#line 32 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	result = _tmp0_;
#line 32 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	return result;
#line 77 "datamodel-test.c"
}


int main (int argc, char ** argv) {
#line 25 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	g_type_init ();
#line 25 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	return _vala_main (argv, argc);
#line 86 "datamodel-test.c"
}


void matches_template_anything_test (void) {
	ZeitgeistEvent* _tmp0_;
	ZeitgeistEvent* templ;
	ZeitgeistEvent* _tmp1_;
	ZeitgeistEvent* event;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	ZeitgeistSubject* _tmp4_;
	ZeitgeistSubject* subject;
	gboolean _tmp5_ = FALSE;
	ZeitgeistSubject* _tmp6_;
	ZeitgeistSubject* subject2;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
#line 38 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp0_ = zeitgeist_event_new_full (NULL, NULL, NULL, NULL, NULL);
#line 38 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	templ = _tmp0_;
#line 39 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp1_ = zeitgeist_event_new_full ("interp", "manif", "actor", "origin", NULL);
#line 39 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	event = _tmp1_;
#line 42 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp2_ = zeitgeist_event_matches_template (templ, templ);
#line 42 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp2_, "templ.matches_template (templ)");
#line 43 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp3_ = zeitgeist_event_matches_template (event, templ);
#line 43 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp3_, "event.matches_template (templ)");
#line 45 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp4_ = zeitgeist_subject_new_full (NULL, NULL, NULL, NULL, NULL, NULL, NULL);
#line 45 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	subject = _tmp4_;
#line 46 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_add_subject (event, subject);
#line 49 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp5_ = zeitgeist_event_matches_template (event, templ);
#line 49 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp5_, "event.matches_template (templ)");
#line 51 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp6_ = zeitgeist_subject_new_full ("uri", "interp", "manif", "mimetype", "origin", "text", "storage");
#line 51 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	subject2 = _tmp6_;
#line 53 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_add_subject (event, subject2);
#line 56 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp7_ = zeitgeist_event_matches_template (event, templ);
#line 56 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp7_, "event.matches_template (templ)");
#line 59 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_interpretation (templ, "");
#line 60 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp8_ = zeitgeist_event_matches_template (event, templ);
#line 60 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp8_, "event.matches_template (templ)");
#line 63 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_actor (templ, "*");
#line 64 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp9_ = zeitgeist_event_matches_template (event, templ);
#line 64 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (_tmp9_, "event.matches_template (templ)");
#line 69 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_manifestation (templ, "No thanks!");
#line 70 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp10_ = zeitgeist_event_matches_template (event, templ);
#line 70 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_vala_assert (!_tmp10_, "!event.matches_template (templ)");
#line 35 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_object_unref0 (subject2);
#line 35 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_object_unref0 (subject);
#line 35 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_object_unref0 (event);
#line 35 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_object_unref0 (templ);
#line 168 "datamodel-test.c"
}


ZeitgeistSubject* create_subject (void) {
	ZeitgeistSubject* result = NULL;
	ZeitgeistSubject* _tmp0_;
	ZeitgeistSubject* s;
#line 75 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp0_ = zeitgeist_subject_new ();
#line 75 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	s = _tmp0_;
#line 76 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_uri (s, "scheme:///uri");
#line 77 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_interpretation (s, "subject_interpretation_uri");
#line 78 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_manifestation (s, "subject_manifestation_uri");
#line 79 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_mimetype (s, "text/plain");
#line 80 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_origin (s, "scheme:///");
#line 81 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_text (s, "Human readable text");
#line 82 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_storage (s, "");
#line 83 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_subject_set_current_uri (s, "scheme:///uri");
#line 85 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	result = s;
#line 85 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	return result;
#line 200 "datamodel-test.c"
}


ZeitgeistEvent* create_event (void) {
	ZeitgeistEvent* result = NULL;
	ZeitgeistEvent* _tmp0_;
	ZeitgeistEvent* e;
#line 90 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp0_ = zeitgeist_event_new ();
#line 90 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	e = _tmp0_;
#line 91 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_id (e, (guint32) 1234);
#line 92 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_timestamp (e, (gint64) 1234567890L);
#line 93 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_interpretation (e, "interpretation_uri");
#line 94 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_manifestation (e, "manifestation_uri");
#line 95 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_actor (e, "test.desktop");
#line 96 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	zeitgeist_event_set_origin (e, "source");
#line 98 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	result = e;
#line 98 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	return result;
#line 228 "datamodel-test.c"
}


static void _g_object_unref0_ (gpointer var) {
#line 103 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
#line 235 "datamodel-test.c"
}


static gpointer _g_object_ref0 (gpointer self) {
#line 109 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	return self ? g_object_ref (self) : NULL;
#line 242 "datamodel-test.c"
}


void foreach_test (void) {
	GPtrArray* _tmp0_;
	GPtrArray* events;
	GPtrArray* _tmp14_;
	ZeitgeistSimpleResultSet* _tmp15_;
	ZeitgeistSimpleResultSet* result_set;
	gint i;
#line 103 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp0_ = g_ptr_array_new_with_free_func (_g_object_unref0_);
#line 103 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	events = _tmp0_;
#line 257 "datamodel-test.c"
	{
		gint i;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		i = 0;
#line 262 "datamodel-test.c"
		{
			gboolean _tmp1_;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp1_ = TRUE;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			while (TRUE) {
#line 269 "datamodel-test.c"
				gboolean _tmp2_;
				gint _tmp4_;
				ZeitgeistEvent* _tmp5_ = NULL;
				ZeitgeistEvent* e;
				ZeitgeistEvent* _tmp6_;
				gint _tmp7_;
				ZeitgeistEvent* _tmp8_;
				ZeitgeistSubject* _tmp9_ = NULL;
				ZeitgeistSubject* _tmp10_;
				GPtrArray* _tmp11_;
				ZeitgeistEvent* _tmp12_;
				ZeitgeistEvent* _tmp13_;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp2_ = _tmp1_;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				if (!_tmp2_) {
#line 286 "datamodel-test.c"
					gint _tmp3_;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
					_tmp3_ = i;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
					i = _tmp3_ + 1;
#line 292 "datamodel-test.c"
				}
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp1_ = FALSE;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp4_ = i;
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				if (!(_tmp4_ < 1000)) {
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
					break;
#line 302 "datamodel-test.c"
				}
#line 106 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp5_ = create_event ();
#line 106 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				e = _tmp5_;
#line 107 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp6_ = e;
#line 107 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp7_ = i;
#line 107 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				zeitgeist_event_set_id (_tmp6_, (guint32) _tmp7_);
#line 108 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp8_ = e;
#line 108 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp9_ = create_subject ();
#line 108 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp10_ = _tmp9_;
#line 108 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				zeitgeist_event_add_subject (_tmp8_, _tmp10_);
#line 108 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_g_object_unref0 (_tmp10_);
#line 109 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp11_ = events;
#line 109 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp12_ = e;
#line 109 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_tmp13_ = _g_object_ref0 (_tmp12_);
#line 109 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				g_ptr_array_add (_tmp11_, _tmp13_);
#line 104 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				_g_object_unref0 (e);
#line 334 "datamodel-test.c"
			}
		}
	}
#line 112 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp14_ = events;
#line 112 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_tmp15_ = zeitgeist_simple_result_set_new (_tmp14_);
#line 112 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	result_set = _tmp15_;
#line 113 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	i = 0;
#line 346 "datamodel-test.c"
	{
		ZeitgeistSimpleResultSet* _tmp16_;
		ZeitgeistResultSet* _tmp17_ = NULL;
		ZeitgeistResultSet* _e_it;
		ZeitgeistEvent* e = NULL;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		_tmp16_ = result_set;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		_tmp17_ = zeitgeist_result_set_iterator ((ZeitgeistResultSet*) _tmp16_);
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		_e_it = _tmp17_;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		while (TRUE) {
#line 360 "datamodel-test.c"
			ZeitgeistResultSet* _tmp18_;
			ZeitgeistEvent* _tmp19_ = NULL;
			ZeitgeistEvent* _tmp20_;
			ZeitgeistEvent* _tmp21_;
			guint32 _tmp22_;
			guint32 _tmp23_;
			gint _tmp24_;
			gint _tmp25_;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp18_ = _e_it;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp19_ = zeitgeist_result_set_next_value (_tmp18_);
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_g_object_unref0 (e);
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			e = _tmp19_;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp20_ = e;
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			if (!(_tmp20_ != NULL)) {
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
				break;
#line 383 "datamodel-test.c"
			}
#line 116 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp21_ = e;
#line 116 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp22_ = zeitgeist_event_get_id (_tmp21_);
#line 116 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp23_ = _tmp22_;
#line 116 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp24_ = i;
#line 116 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			g_assert_cmpint ((gint) _tmp23_, ==, _tmp24_);
#line 117 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			_tmp25_ = i;
#line 117 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
			i = _tmp25_ + 1;
#line 399 "datamodel-test.c"
		}
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		_g_object_unref0 (e);
#line 114 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
		_g_object_unref0 (_e_it);
#line 405 "datamodel-test.c"
	}
#line 101 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_object_unref0 (result_set);
#line 101 "/home/manish/code/zeitgeist/test/direct/datamodel-test.vala"
	_g_ptr_array_unref0 (events);
#line 411 "datamodel-test.c"
}



