/* test_config_modifier.c generated by valac 0.56.19, the Vala compiler
 * generated from test_config_modifier.vala, do not modify */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))

#define WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG (wm_config_modifier_xkb_config_get_type ())
#define WM_CONFIG_MODIFIER_XKB_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfig))
#define WM_CONFIG_MODIFIER_XKB_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfigClass))
#define WM_CONFIG_MODIFIER_IS_XKB_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG))
#define WM_CONFIG_MODIFIER_IS_XKB_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG))
#define WM_CONFIG_MODIFIER_XKB_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfigClass))

typedef struct _WMConfigModifierXKBConfig WMConfigModifierXKBConfig;
typedef struct _WMConfigModifierXKBConfigClass WMConfigModifierXKBConfigClass;
#define _wm_config_modifier_xkb_config_unref0(var) ((var == NULL) ? NULL : (var = (wm_config_modifier_xkb_config_unref (var), NULL)))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

VALA_EXTERN void test_env_exports_idempotent (void);
VALA_EXTERN gpointer wm_config_modifier_xkb_config_ref (gpointer instance);
VALA_EXTERN void wm_config_modifier_xkb_config_unref (gpointer instance);
VALA_EXTERN GParamSpec* wm_config_modifier_param_spec_xkb_config (const gchar* name,
                                                      const gchar* nick,
                                                      const gchar* blurb,
                                                      GType object_type,
                                                      GParamFlags flags);
VALA_EXTERN void wm_config_modifier_value_set_xkb_config (GValue* value,
                                              gpointer v_object);
VALA_EXTERN void wm_config_modifier_value_take_xkb_config (GValue* value,
                                               gpointer v_object);
VALA_EXTERN gpointer wm_config_modifier_value_get_xkb_config (const GValue* value);
VALA_EXTERN GType wm_config_modifier_xkb_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WMConfigModifierXKBConfig, wm_config_modifier_xkb_config_unref)
VALA_EXTERN WMConfigModifierXKBConfig* wm_config_modifier_xkb_config_new (void);
VALA_EXTERN WMConfigModifierXKBConfig* wm_config_modifier_xkb_config_construct (GType object_type);
VALA_EXTERN void wm_config_modifier_xkb_config_set_layout (WMConfigModifierXKBConfig* self,
                                               const gchar* value);
VALA_EXTERN void wm_config_modifier_xkb_config_set_options (WMConfigModifierXKBConfig* self,
                                                const gchar* value);
VALA_EXTERN gboolean wm_config_modifier_test_apply_env_exports (const gchar* path,
                                                    WMConfigModifierXKBConfig* config,
                                                    GError** error);
VALA_EXTERN void test_env_exports_preserves_content (void);
VALA_EXTERN void test_env_exports_migrates_legacy_markers (void);
VALA_EXTERN void test_options_merge_preserves_compose (void);
static void _g_free0_ (gpointer var);
static void _vala_gchar_free_function_content_of (gpointer data);
VALA_EXTERN void test_flag_utils_strip_variant_to_base (void);
VALA_EXTERN gchar* flag_utils_get_layout_base_code (const gchar* code);
VALA_EXTERN void test_flag_utils_arabic_uses_existing_flag_asset_code (void);
VALA_EXTERN gchar* flag_utils_get_layout_icon_code (const gchar* layout_code);
VALA_EXTERN void test_flag_utils_estonian_uses_et_asset_code (void);
static gint _vala_main (gchar** args,
                 gint args_length1);
static void _test_env_exports_idempotent_gtest_func (void);
static void _test_env_exports_preserves_content_gtest_func (void);
static void _test_options_merge_preserves_compose_gtest_func (void);
static void _test_env_exports_migrates_legacy_markers_gtest_func (void);
static void _test_flag_utils_strip_variant_to_base_gtest_func (void);
static void _test_flag_utils_arabic_uses_existing_flag_asset_code_gtest_func (void);
static void _test_flag_utils_estonian_uses_et_asset_code_gtest_func (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

void
test_env_exports_idempotent (void)
{
	gchar* tmpfile = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	WMConfigModifierXKBConfig* cfg = NULL;
	WMConfigModifierXKBConfig* _tmp6_;
	WMConfigModifierXKBConfig* _tmp7_;
	WMConfigModifierXKBConfig* _tmp8_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = g_get_tmp_dir ();
	_tmp1_ = g_strdup_printf ("kbd_test_%u.txt", (guint) g_random_int ());
	_tmp2_ = _tmp1_;
	_tmp3_ = g_build_filename (_tmp0_, _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	tmpfile = _tmp4_;
	_tmp5_ = tmpfile;
	g_file_set_contents (_tmp5_, "#!/bin/bash\nwaybar &\nwl-paste --watch cliphist store &\n", (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp6_ = wm_config_modifier_xkb_config_new ();
	cfg = _tmp6_;
	_tmp7_ = cfg;
	wm_config_modifier_xkb_config_set_layout (_tmp7_, "us,ru");
	_tmp8_ = cfg;
	wm_config_modifier_xkb_config_set_options (_tmp8_, "grp:alt_shift_toggle");
	{
		const gchar* _tmp9_;
		WMConfigModifierXKBConfig* _tmp10_;
		gchar* after1 = NULL;
		const gchar* _tmp11_;
		gchar* _tmp12_ = NULL;
		const gchar* _tmp13_;
		WMConfigModifierXKBConfig* _tmp14_;
		gchar* after2 = NULL;
		const gchar* _tmp15_;
		gchar* _tmp16_ = NULL;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		_tmp9_ = tmpfile;
		_tmp10_ = cfg;
		wm_config_modifier_test_apply_env_exports (_tmp9_, _tmp10_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp11_ = tmpfile;
		g_file_get_contents (_tmp11_, &_tmp12_, NULL, &_inner_error0_);
		_g_free0 (after1);
		after1 = _tmp12_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (after1);
			goto __catch0_g_error;
		}
		_tmp13_ = tmpfile;
		_tmp14_ = cfg;
		wm_config_modifier_test_apply_env_exports (_tmp13_, _tmp14_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (after1);
			goto __catch0_g_error;
		}
		_tmp15_ = tmpfile;
		g_file_get_contents (_tmp15_, &_tmp16_, NULL, &_inner_error0_);
		_g_free0 (after2);
		after2 = _tmp16_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (after2);
			_g_free0 (after1);
			goto __catch0_g_error;
		}
		_tmp17_ = after1;
		_tmp18_ = after2;
		g_assert_true (g_strcmp0 (_tmp17_, _tmp18_) == 0);
		_g_free0 (after2);
		_g_free0 (after1);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	{
		GError* _inner_error1_ = NULL;
		const gchar* _tmp19_;
		_tmp19_ = tmpfile;
		g_remove (_tmp19_);
	}
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_wm_config_modifier_xkb_config_unref0 (cfg);
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_wm_config_modifier_xkb_config_unref0 (cfg);
	_g_free0 (tmpfile);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

void
test_env_exports_preserves_content (void)
{
	gchar* tmpfile = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	WMConfigModifierXKBConfig* cfg = NULL;
	WMConfigModifierXKBConfig* _tmp5_;
	WMConfigModifierXKBConfig* _tmp6_;
	WMConfigModifierXKBConfig* _tmp7_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = g_get_tmp_dir ();
	_tmp1_ = g_strdup_printf ("kbd_test_%u.txt", (guint) g_random_int ());
	_tmp2_ = _tmp1_;
	_tmp3_ = g_build_filename (_tmp0_, _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	tmpfile = _tmp4_;
	g_file_set_contents (tmpfile, "#!/bin/bash\nwaybar &\nwl-paste --watch cliphist store &\n", (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp5_ = wm_config_modifier_xkb_config_new ();
	cfg = _tmp5_;
	_tmp6_ = cfg;
	wm_config_modifier_xkb_config_set_layout (_tmp6_, "us,ru");
	_tmp7_ = cfg;
	wm_config_modifier_xkb_config_set_options (_tmp7_, "grp:alt_shift_toggle");
	{
		WMConfigModifierXKBConfig* _tmp8_;
		gchar* _result_ = NULL;
		gchar* _tmp9_ = NULL;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		_tmp8_ = cfg;
		wm_config_modifier_test_apply_env_exports (tmpfile, _tmp8_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		g_file_get_contents (tmpfile, &_tmp9_, NULL, &_inner_error0_);
		_g_free0 (_result_);
		_result_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (_result_);
			goto __catch0_g_error;
		}
		_tmp10_ = _result_;
		g_assert_true (string_contains (_tmp10_, "waybar &"));
		_tmp11_ = _result_;
		g_assert_true (string_contains (_tmp11_, "wl-paste"));
		_tmp12_ = _result_;
		g_assert_true (string_contains (_tmp12_, "BEGIN wl-kbd-config"));
		_tmp13_ = _result_;
		g_assert_true (string_contains (_tmp13_, "XKB_DEFAULT_LAYOUT=\"us,ru\""));
		_tmp14_ = _result_;
		g_assert_true (string_contains (_tmp14_, "XKB_DEFAULT_OPTIONS=\"grp:alt_shift_toggle\""));
		_g_free0 (_result_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	{
		GError* _inner_error1_ = NULL;
		g_remove (tmpfile);
	}
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_wm_config_modifier_xkb_config_unref0 (cfg);
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_wm_config_modifier_xkb_config_unref0 (cfg);
	_g_free0 (tmpfile);
}

void
test_env_exports_migrates_legacy_markers (void)
{
	gchar* tmpfile = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	WMConfigModifierXKBConfig* cfg = NULL;
	WMConfigModifierXKBConfig* _tmp5_;
	WMConfigModifierXKBConfig* _tmp6_;
	WMConfigModifierXKBConfig* _tmp7_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = g_get_tmp_dir ();
	_tmp1_ = g_strdup_printf ("kbd_test_%u.txt", (guint) g_random_int ());
	_tmp2_ = _tmp1_;
	_tmp3_ = g_build_filename (_tmp0_, _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	tmpfile = _tmp4_;
	g_file_set_contents (tmpfile, "before\n" \
"# BEGIN labwc-kbd\n" \
"export XKB_DEFAULT_LAYOUT=\"de\"\n" \
"# END labwc-kbd\n" \
"after\n", (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp5_ = wm_config_modifier_xkb_config_new ();
	cfg = _tmp5_;
	_tmp6_ = cfg;
	wm_config_modifier_xkb_config_set_layout (_tmp6_, "us,ru");
	_tmp7_ = cfg;
	wm_config_modifier_xkb_config_set_options (_tmp7_, "grp:alt_shift_toggle");
	{
		WMConfigModifierXKBConfig* _tmp8_;
		gchar* _result_ = NULL;
		gchar* _tmp9_ = NULL;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		_tmp8_ = cfg;
		wm_config_modifier_test_apply_env_exports (tmpfile, _tmp8_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		g_file_get_contents (tmpfile, &_tmp9_, NULL, &_inner_error0_);
		_g_free0 (_result_);
		_result_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (_result_);
			goto __catch0_g_error;
		}
		_tmp10_ = _result_;
		g_assert_false (string_contains (_tmp10_, "# BEGIN labwc-kbd"));
		_tmp11_ = _result_;
		g_assert_false (string_contains (_tmp11_, "# END labwc-kbd"));
		_tmp12_ = _result_;
		g_assert_true (string_contains (_tmp12_, "# BEGIN wl-kbd-config"));
		_tmp13_ = _result_;
		g_assert_true (string_contains (_tmp13_, "# END wl-kbd-config"));
		_g_free0 (_result_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	{
		GError* _inner_error1_ = NULL;
		g_remove (tmpfile);
	}
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_wm_config_modifier_xkb_config_unref0 (cfg);
		_g_free0 (tmpfile);
		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);
		g_clear_error (&_inner_error0_);
		return;
	}
	_wm_config_modifier_xkb_config_unref0 (cfg);
	_g_free0 (tmpfile);
}

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

static void
_vala_gchar_free_function_content_of (gpointer data)
{
	gchar* self;
	self = *((gchar**) data);
	_g_free0_ (self);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

void
test_options_merge_preserves_compose (void)
{
	gchar* existing = NULL;
	gchar* _tmp0_;
	gchar* new_grp = NULL;
	gchar* _tmp1_;
	GArray* parts = NULL;
	GArray* _tmp2_;
	const gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	const gchar* _tmp14_;
	gchar* merged = NULL;
	GArray* _tmp18_;
	gpointer* _tmp19_;
	gint _tmp19__length1;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gint count = 0;
	const gchar* _tmp25_;
	gchar** _tmp26_;
	gchar** _tmp27_;
	_tmp0_ = g_strdup ("compose:ralt,caps:escape,grp:shifts_toggle");
	existing = _tmp0_;
	_tmp1_ = g_strdup ("grp:alt_shift_toggle");
	new_grp = _tmp1_;
	_tmp2_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp2_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	parts = _tmp2_;
	_tmp3_ = existing;
	_tmp5_ = _tmp4_ = g_strsplit (_tmp3_, ",", 0);
	{
		gchar** p_collection = NULL;
		gint p_collection_length1 = 0;
		gint _p_collection_size_ = 0;
		gint p_it = 0;
		p_collection = _tmp5_;
		p_collection_length1 = _vala_array_length (_tmp4_);
		for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) {
			const gchar* p = NULL;
			p = p_collection[p_it];
			{
				gchar* t = NULL;
				const gchar* _tmp6_;
				gchar* _tmp7_;
				gboolean _tmp8_ = FALSE;
				const gchar* _tmp9_;
				_tmp6_ = p;
				_tmp7_ = string_strip (_tmp6_);
				t = _tmp7_;
				_tmp9_ = t;
				if (g_strcmp0 (_tmp9_, "") != 0) {
					const gchar* _tmp10_;
					_tmp10_ = t;
					_tmp8_ = !g_str_has_prefix (_tmp10_, "grp:");
				} else {
					_tmp8_ = FALSE;
				}
				if (_tmp8_) {
					GArray* _tmp11_;
					const gchar* _tmp12_;
					gchar* _tmp13_;
					_tmp11_ = parts;
					_tmp12_ = t;
					_tmp13_ = g_strdup (_tmp12_);
					g_array_append_val (_tmp11_, _tmp13_);
				}
				_g_free0 (t);
			}
		}
		p_collection = (_vala_array_free (p_collection, p_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp14_ = new_grp;
	if (g_strcmp0 (_tmp14_, "") != 0) {
		GArray* _tmp15_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		_tmp15_ = parts;
		_tmp16_ = new_grp;
		_tmp17_ = g_strdup (_tmp16_);
		g_array_append_val (_tmp15_, _tmp17_);
	}
	_tmp18_ = parts;
	_tmp19_ = _tmp18_->data;
	_tmp19__length1 = _tmp18_->len;
	_tmp20_ = _vala_g_strjoinv (",", _tmp19_, (gint) _tmp19__length1);
	merged = _tmp20_;
	_tmp21_ = merged;
	g_assert_true (string_contains (_tmp21_, "compose:ralt"));
	_tmp22_ = merged;
	g_assert_true (string_contains (_tmp22_, "caps:escape"));
	_tmp23_ = merged;
	g_assert_true (string_contains (_tmp23_, "grp:alt_shift_toggle"));
	_tmp24_ = merged;
	g_assert_false (string_contains (_tmp24_, "grp:shifts_toggle"));
	count = 0;
	_tmp25_ = merged;
	_tmp27_ = _tmp26_ = g_strsplit (_tmp25_, ",", 0);
	{
		gchar** p_collection = NULL;
		gint p_collection_length1 = 0;
		gint _p_collection_size_ = 0;
		gint p_it = 0;
		p_collection = _tmp27_;
		p_collection_length1 = _vala_array_length (_tmp26_);
		for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) {
			const gchar* p = NULL;
			p = p_collection[p_it];
			{
				const gchar* _tmp28_;
				_tmp28_ = p;
				if (g_str_has_prefix (_tmp28_, "grp:")) {
					gint _tmp29_;
					_tmp29_ = count;
					count = _tmp29_ + 1;
				}
			}
		}
		p_collection = (_vala_array_free (p_collection, p_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	g_assert_true (count == 1);
	_g_free0 (merged);
	_g_array_unref0 (parts);
	_g_free0 (new_grp);
	_g_free0 (existing);
}

void
test_flag_utils_strip_variant_to_base (void)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = flag_utils_get_layout_base_code ("us(intl)");
	_tmp1_ = _tmp0_;
	g_assert_true (g_strcmp0 (_tmp1_, "us") == 0);
	_g_free0 (_tmp1_);
	_tmp2_ = flag_utils_get_layout_base_code ("de(nodeadkeys)");
	_tmp3_ = _tmp2_;
	g_assert_true (g_strcmp0 (_tmp3_, "de") == 0);
	_g_free0 (_tmp3_);
}

void
test_flag_utils_arabic_uses_existing_flag_asset_code (void)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = flag_utils_get_layout_icon_code ("ara");
	_tmp1_ = _tmp0_;
	g_assert_true (g_strcmp0 (_tmp1_, "ar") == 0);
	_g_free0 (_tmp1_);
	_tmp2_ = flag_utils_get_layout_icon_code ("arabic");
	_tmp3_ = _tmp2_;
	g_assert_true (g_strcmp0 (_tmp3_, "ar") == 0);
	_g_free0 (_tmp3_);
}

void
test_flag_utils_estonian_uses_et_asset_code (void)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = flag_utils_get_layout_icon_code ("ee");
	_tmp1_ = _tmp0_;
	g_assert_true (g_strcmp0 (_tmp1_, "et") == 0);
	_g_free0 (_tmp1_);
	_tmp2_ = flag_utils_get_layout_icon_code ("estonian");
	_tmp3_ = _tmp2_;
	g_assert_true (g_strcmp0 (_tmp3_, "et") == 0);
	_g_free0 (_tmp3_);
}

static void
_test_env_exports_idempotent_gtest_func (void)
{
	test_env_exports_idempotent ();
}

static void
_test_env_exports_preserves_content_gtest_func (void)
{
	test_env_exports_preserves_content ();
}

static void
_test_options_merge_preserves_compose_gtest_func (void)
{
	test_options_merge_preserves_compose ();
}

static void
_test_env_exports_migrates_legacy_markers_gtest_func (void)
{
	test_env_exports_migrates_legacy_markers ();
}

static void
_test_flag_utils_strip_variant_to_base_gtest_func (void)
{
	test_flag_utils_strip_variant_to_base ();
}

static void
_test_flag_utils_arabic_uses_existing_flag_asset_code_gtest_func (void)
{
	test_flag_utils_arabic_uses_existing_flag_asset_code ();
}

static void
_test_flag_utils_estonian_uses_et_asset_code_gtest_func (void)
{
	test_flag_utils_estonian_uses_et_asset_code ();
}

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	gint result;
	g_test_init ((gint*) (&args_length1), &args, NULL);
	g_test_add_func ("/config/env_exports_idempotent", _test_env_exports_idempotent_gtest_func);
	g_test_add_func ("/config/env_exports_preserves", _test_env_exports_preserves_content_gtest_func);
	g_test_add_func ("/config/options_merge_preserves", _test_options_merge_preserves_compose_gtest_func);
	g_test_add_func ("/config/migrate_legacy_markers", _test_env_exports_migrates_legacy_markers_gtest_func);
	g_test_add_func ("/flags/strip_variant_to_base", _test_flag_utils_strip_variant_to_base_gtest_func);
	g_test_add_func ("/flags/arabic_maps_to_ar", _test_flag_utils_arabic_uses_existing_flag_asset_code_gtest_func);
	g_test_add_func ("/flags/estonian_maps_to_et", _test_flag_utils_estonian_uses_et_asset_code_gtest_func);
	result = g_test_run ();
	return result;
}

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

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

