/* field-details.c generated by valac 0.12.0, the Vala compiler
 * generated from field-details.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <stdlib.h>
#include <string.h>
#include <folks/folks.h>
#include <gee.h>


#define TYPE_FIELD_DETAILS_TESTS (field_details_tests_get_type ())
#define FIELD_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FIELD_DETAILS_TESTS, FieldDetailsTests))
#define FIELD_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FIELD_DETAILS_TESTS, FieldDetailsTestsClass))
#define IS_FIELD_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FIELD_DETAILS_TESTS))
#define IS_FIELD_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FIELD_DETAILS_TESTS))
#define FIELD_DETAILS_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FIELD_DETAILS_TESTS, FieldDetailsTestsClass))

typedef struct _FieldDetailsTests FieldDetailsTests;
typedef struct _FieldDetailsTestsClass FieldDetailsTestsClass;
typedef struct _FieldDetailsTestsPrivate FieldDetailsTestsPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))

struct _FieldDetailsTests {
	FolksTestCase parent_instance;
	FieldDetailsTestsPrivate * priv;
};

struct _FieldDetailsTestsClass {
	FolksTestCaseClass parent_class;
};


static gpointer field_details_tests_parent_class = NULL;

GType field_details_tests_get_type (void) G_GNUC_CONST;
enum  {
	FIELD_DETAILS_TESTS_DUMMY_PROPERTY
};
FieldDetailsTests* field_details_tests_new (void);
FieldDetailsTests* field_details_tests_construct (GType object_type);
void field_details_tests_test_param_replacement (FieldDetailsTests* self);
static void _field_details_tests_test_param_replacement_folks_test_case_test_method (gpointer self);
static void field_details_tests_real_set_up (FolksTestCase* base);
static void field_details_tests_real_tear_down (FolksTestCase* base);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
gint _vala_main (gchar** args, int args_length1);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void _field_details_tests_test_param_replacement_folks_test_case_test_method (gpointer self) {
	field_details_tests_test_param_replacement (self);
}


FieldDetailsTests* field_details_tests_construct (GType object_type) {
	FieldDetailsTests * self = NULL;
	self = (FieldDetailsTests*) folks_test_case_construct (object_type, "FieldDetails");
	folks_test_case_add_test ((FolksTestCase*) self, "parameter replacement", _field_details_tests_test_param_replacement_folks_test_case_test_method, self);
	return self;
}


FieldDetailsTests* field_details_tests_new (void) {
	return field_details_tests_construct (TYPE_FIELD_DETAILS_TESTS);
}


static void field_details_tests_real_set_up (FolksTestCase* base) {
	FieldDetailsTests * self;
	self = (FieldDetailsTests*) base;
}


static void field_details_tests_real_tear_down (FolksTestCase* base) {
	FieldDetailsTests * self;
	self = (FieldDetailsTests*) base;
}


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


static void _g_list_free__g_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_free0_, NULL);
	g_list_free (self);
}


void field_details_tests_test_param_replacement (FieldDetailsTests* self) {
	gchar* _tmp0_;
	gchar* param_name;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_ = NULL;
	gchar** values_1;
	gint values_1_length1;
	gint _values_1_size_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_ = NULL;
	gchar** values_2;
	gint values_2_length1;
	gint _values_2_size_;
	FolksFieldDetails* details = NULL;
	GeeCollection* values = NULL;
	FolksFieldDetails* _tmp8_ = NULL;
	GeeCollection* _tmp10_ = NULL;
	gint _tmp11_;
	GeeCollection* _tmp14_ = NULL;
	gint _tmp15_;
	gboolean _tmp16_;
	GeeCollection* _tmp17_ = NULL;
	GList* values_2_list;
	GeeHashMultiMap* _tmp21_ = NULL;
	GeeHashMultiMap* param_table;
	GeeCollection* _tmp23_ = NULL;
	gint _tmp24_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("metasyntactic-variables");
	param_name = _tmp0_;
	_tmp1_ = g_strdup ("foo");
	_tmp2_ = g_strdup ("bar");
	_tmp3_ = g_strdup ("baz");
	_tmp4_ = g_new0 (gchar*, 3 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp2_;
	_tmp4_[2] = _tmp3_;
	values_1 = _tmp4_;
	values_1_length1 = 3;
	_values_1_size_ = 3;
	_tmp5_ = g_strdup ("qux");
	_tmp6_ = g_strdup ("quxx");
	_tmp7_ = g_new0 (gchar*, 2 + 1);
	_tmp7_[0] = _tmp5_;
	_tmp7_[1] = _tmp6_;
	values_2 = _tmp7_;
	values_2_length1 = 2;
	_values_2_size_ = 2;
	_tmp8_ = folks_field_details_new (param_name);
	_g_object_unref0 (details);
	details = _tmp8_;
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_1;
		val_collection_length1 = values_1_length1;
		for (val_it = 0; val_it < values_1_length1; val_it = val_it + 1) {
			gchar* _tmp9_;
			gchar* val;
			_tmp9_ = g_strdup (val_collection[val_it]);
			val = _tmp9_;
			{
				folks_field_details_add_parameter (details, param_name, val);
				_g_free0 (val);
			}
		}
	}
	_tmp10_ = folks_field_details_get_parameter_values (details, param_name);
	_g_object_unref0 (values);
	values = _tmp10_;
	_tmp11_ = gee_collection_get_size (values);
	g_assert (_tmp11_ == values_1_length1);
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_1;
		val_collection_length1 = values_1_length1;
		for (val_it = 0; val_it < values_1_length1; val_it = val_it + 1) {
			gchar* _tmp12_;
			gchar* val;
			_tmp12_ = g_strdup (val_collection[val_it]);
			val = _tmp12_;
			{
				gboolean _tmp13_;
				_tmp13_ = gee_collection_contains (values, val);
				g_assert (_tmp13_);
				_g_free0 (val);
			}
		}
	}
	folks_field_details_set_parameter (details, param_name, values_2[0]);
	_tmp14_ = folks_field_details_get_parameter_values (details, param_name);
	_g_object_unref0 (values);
	values = _tmp14_;
	_tmp15_ = gee_collection_get_size (values);
	g_assert (_tmp15_ == 1);
	_tmp16_ = gee_collection_contains (values, values_2[0]);
	g_assert (_tmp16_);
	folks_field_details_remove_parameter_all (details, param_name);
	_tmp17_ = folks_field_details_get_parameter_values (details, param_name);
	_g_object_unref0 (values);
	values = _tmp17_;
	g_assert (values == NULL);
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_1;
		val_collection_length1 = values_1_length1;
		for (val_it = 0; val_it < values_1_length1; val_it = val_it + 1) {
			gchar* _tmp18_;
			gchar* val;
			_tmp18_ = g_strdup (val_collection[val_it]);
			val = _tmp18_;
			{
				folks_field_details_add_parameter (details, param_name, val);
				_g_free0 (val);
			}
		}
	}
	values_2_list = NULL;
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_2;
		val_collection_length1 = values_2_length1;
		for (val_it = 0; val_it < values_2_length1; val_it = val_it + 1) {
			gchar* _tmp19_;
			gchar* val;
			_tmp19_ = g_strdup (val_collection[val_it]);
			val = _tmp19_;
			{
				gchar* _tmp20_;
				_tmp20_ = g_strdup (val);
				values_2_list = g_list_append (values_2_list, _tmp20_);
				_g_free0 (val);
			}
		}
	}
	_tmp21_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL, NULL);
	param_table = _tmp21_;
	{
		GList* val_collection;
		GList* val_it;
		val_collection = values_2_list;
		for (val_it = val_collection; val_it != NULL; val_it = val_it->next) {
			gchar* _tmp22_;
			gchar* val;
			_tmp22_ = g_strdup ((const gchar*) val_it->data);
			val = _tmp22_;
			{
				gee_multi_map_set ((GeeMultiMap*) param_table, param_name, val);
				_g_free0 (val);
			}
		}
	}
	folks_field_details_extend_parameters (details, (GeeMultiMap*) param_table);
	_tmp23_ = folks_field_details_get_parameter_values (details, param_name);
	_g_object_unref0 (values);
	values = _tmp23_;
	_tmp24_ = gee_collection_get_size (values);
	g_assert (_tmp24_ == (values_1_length1 + values_2_length1));
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_1;
		val_collection_length1 = values_1_length1;
		for (val_it = 0; val_it < values_1_length1; val_it = val_it + 1) {
			gchar* _tmp25_;
			gchar* val;
			_tmp25_ = g_strdup (val_collection[val_it]);
			val = _tmp25_;
			{
				gboolean _tmp26_;
				_tmp26_ = gee_collection_contains (values, val);
				g_assert (_tmp26_);
				_g_free0 (val);
			}
		}
	}
	{
		gchar** val_collection;
		int val_collection_length1;
		int val_it;
		val_collection = values_2;
		val_collection_length1 = values_2_length1;
		for (val_it = 0; val_it < values_2_length1; val_it = val_it + 1) {
			gchar* _tmp27_;
			gchar* val;
			_tmp27_ = g_strdup (val_collection[val_it]);
			val = _tmp27_;
			{
				gboolean _tmp28_;
				_tmp28_ = gee_collection_contains (values, val);
				g_assert (_tmp28_);
				_g_free0 (val);
			}
		}
	}
	_g_object_unref0 (param_table);
	__g_list_free__g_free0_0 (values_2_list);
	_g_object_unref0 (values);
	_g_object_unref0 (details);
	values_2 = (_vala_array_free (values_2, values_2_length1, (GDestroyNotify) g_free), NULL);
	values_1 = (_vala_array_free (values_1, values_1_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (param_name);
}


static void field_details_tests_class_init (FieldDetailsTestsClass * klass) {
	field_details_tests_parent_class = g_type_class_peek_parent (klass);
	FOLKS_TEST_CASE_CLASS (klass)->set_up = field_details_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = field_details_tests_real_tear_down;
}


static void field_details_tests_instance_init (FieldDetailsTests * self) {
}


GType field_details_tests_get_type (void) {
	static volatile gsize field_details_tests_type_id__volatile = 0;
	if (g_once_init_enter (&field_details_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FieldDetailsTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) field_details_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FieldDetailsTests), 0, (GInstanceInitFunc) field_details_tests_instance_init, NULL };
		GType field_details_tests_type_id;
		field_details_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "FieldDetailsTests", &g_define_type_info, 0);
		g_once_init_leave (&field_details_tests_type_id__volatile, field_details_tests_type_id);
	}
	return field_details_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	FieldDetailsTests* _tmp1_ = NULL;
	FieldDetailsTests* _tmp2_;
	GTestSuite* _tmp3_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = field_details_tests_new ();
	_tmp2_ = _tmp1_;
	_tmp3_ = folks_test_case_get_suite ((FolksTestCase*) _tmp2_);
	g_test_suite_add_suite (root, _tmp3_);
	_g_object_unref0 (_tmp2_);
	g_test_run ();
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	return _vala_main (argv, argc);
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



