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

/*
Copyright (C) 2012, 2014 Johan Mattsson

This library 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 3 of the 
License, or (at your option) any later version.

This library 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 
Lesser General Public License for more details.
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "birdfont.h"
#include <stdio.h>
#include <float.h>
#include <math.h>

#define BIRD_FONT_TEST_BIRD_FONT_NOT_STARTED 0
#define BIRD_FONT_TEST_BIRD_FONT_RUNNING 1
#define BIRD_FONT_TEST_BIRD_FONT_PAUSED 2
#define BIRD_FONT_TEST_BIRD_FONT_DONE 3
#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

#define BIRD_FONT_TYPE_TEST_BIRD_FONT (bird_font_test_bird_font_get_type ())
#define BIRD_FONT_TEST_BIRD_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_TEST_BIRD_FONT, BirdFontTestBirdFont))
#define BIRD_FONT_TEST_BIRD_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_TEST_BIRD_FONT, BirdFontTestBirdFontClass))
#define BIRD_FONT_IS_TEST_BIRD_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_TEST_BIRD_FONT))
#define BIRD_FONT_IS_TEST_BIRD_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_TEST_BIRD_FONT))
#define BIRD_FONT_TEST_BIRD_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_TEST_BIRD_FONT, BirdFontTestBirdFontClass))

typedef struct _BirdFontTestBirdFont BirdFontTestBirdFont;
typedef struct _BirdFontTestBirdFontClass BirdFontTestBirdFontClass;
typedef struct _BirdFontTestBirdFontPrivate BirdFontTestBirdFontPrivate;

#define BIRD_FONT_TYPE_TEST_CASES (bird_font_test_cases_get_type ())
#define BIRD_FONT_TEST_CASES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_TEST_CASES, BirdFontTestCases))
#define BIRD_FONT_TEST_CASES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_TEST_CASES, BirdFontTestCasesClass))
#define BIRD_FONT_IS_TEST_CASES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_TEST_CASES))
#define BIRD_FONT_IS_TEST_CASES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_TEST_CASES))
#define BIRD_FONT_TEST_CASES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_TEST_CASES, BirdFontTestCasesClass))

typedef struct _BirdFontTestCases BirdFontTestCases;
typedef struct _BirdFontTestCasesClass BirdFontTestCasesClass;
enum  {
	BIRD_FONT_TEST_BIRD_FONT_0_PROPERTY,
	BIRD_FONT_TEST_BIRD_FONT_NUM_PROPERTIES
};
static GParamSpec* bird_font_test_bird_font_properties[BIRD_FONT_TEST_BIRD_FONT_NUM_PROPERTIES];
#define _bird_font_test_cases_unref0(var) ((var == NULL) ? NULL : (var = (bird_font_test_cases_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_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);

struct _BirdFontTestBirdFont {
	GObject parent_instance;
	BirdFontTestBirdFontPrivate * priv;
	gchar* test_cases_to_run;
};

struct _BirdFontTestBirdFontClass {
	GObjectClass parent_class;
};

struct _BirdFontTestBirdFontPrivate {
	BirdFontTestCases* tests;
	GList* test_cases;
	GList* current_case;
	GList* passed;
	GList* failed;
	GList* skipped;
	GList* bechmarks;
	gboolean has_failed;
	gboolean has_skipped;
};

static gint BirdFontTestBirdFont_private_offset;
static gpointer bird_font_test_bird_font_parent_class = NULL;
static gint bird_font_test_bird_font_state;
static gint bird_font_test_bird_font_state = BIRD_FONT_TEST_BIRD_FONT_NOT_STARTED;
static BirdFontTestBirdFont* bird_font_test_bird_font_singleton;
static BirdFontTestBirdFont* bird_font_test_bird_font_singleton = NULL;
static gboolean bird_font_test_bird_font_slow_test;
static gboolean bird_font_test_bird_font_slow_test = FALSE;

VALA_EXTERN GType bird_font_test_bird_font_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer bird_font_test_cases_ref (gpointer instance);
VALA_EXTERN void bird_font_test_cases_unref (gpointer instance);
VALA_EXTERN GParamSpec* bird_font_param_spec_test_cases (const gchar* name,
                                             const gchar* nick,
                                             const gchar* blurb,
                                             GType object_type,
                                             GParamFlags flags);
VALA_EXTERN void bird_font_value_set_test_cases (GValue* value,
                                     gpointer v_object);
VALA_EXTERN void bird_font_value_take_test_cases (GValue* value,
                                      gpointer v_object);
VALA_EXTERN gpointer bird_font_value_get_test_cases (const GValue* value);
VALA_EXTERN GType bird_font_test_cases_get_type (void) G_GNUC_CONST ;
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN BirdFontTestBirdFont* bird_font_test_bird_font_new (void);
VALA_EXTERN BirdFontTestBirdFont* bird_font_test_bird_font_construct (GType object_type);
VALA_EXTERN BirdFontTestCases* bird_font_test_cases_new (void);
VALA_EXTERN BirdFontTestCases* bird_font_test_cases_construct (GType object_type);
VALA_EXTERN GList* bird_font_test_cases_get_test_functions (BirdFontTestCases* self);
static void bird_font_test_bird_font_from_command_line (BirdFontTestBirdFont* self);
VALA_EXTERN gboolean bird_font_test_bird_font_is_slow_test (void);
VALA_EXTERN void bird_font_test_bird_font_set_slow_test (gboolean s);
VALA_EXTERN void bird_font_test_bird_font_run_tests (void);
VALA_EXTERN BirdFontTestBirdFont* bird_font_test_bird_font_get_singleton (void);
VALA_EXTERN void bird_font_test_bird_font_run_all_tests (BirdFontTestBirdFont* self);
static gboolean bird_font_test_bird_font_has_test_case (BirdFontTestBirdFont* self,
                                                 const gchar* s);
VALA_EXTERN gchar* bird_font_bird_font_get_argument (const gchar* param);
VALA_EXTERN void bird_font_test_bird_font_log (const gchar* log_domain,
                                   GLogLevelFlags log_levels,
                                   const gchar* message);
VALA_EXTERN void bird_font_test_bird_font_continue (void);
static void _bird_font_test_bird_font_log_glog_func (const gchar* log_domain,
                                              GLogLevelFlags log_levels,
                                              const gchar* message,
                                              gpointer self);
VALA_EXTERN gboolean bird_font_test_bird_font_is_running (void);
VALA_EXTERN void bird_font_test_bird_font_pause (void);
static void bird_font_test_bird_font_pad (gint t);
VALA_EXTERN void bird_font_test_bird_font_print_result (BirdFontTestBirdFont* self);
static gboolean __lambda220_ (BirdFontTestBirdFont* self);
static gboolean ___lambda220__gsource_func (gpointer self);
static void bird_font_test_bird_font_finalize (GObject * obj);
static GType bird_font_test_bird_font_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_test_bird_font_get_instance_private (BirdFontTestBirdFont* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontTestBirdFont_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

BirdFontTestBirdFont*
bird_font_test_bird_font_construct (GType object_type)
{
	BirdFontTestBirdFont * self = NULL;
	BirdFontTestBirdFont* _tmp0_;
	BirdFontTestCases* _tmp1_;
	BirdFontTestCases* _tmp2_;
	GList* _tmp3_;
	GList* _tmp4_;
	GList* _tmp5_;
	gchar* _tmp6_;
	self = (BirdFontTestBirdFont*) g_object_new (object_type, NULL);
	_tmp0_ = bird_font_test_bird_font_singleton;
	_vala_assert (_tmp0_ == NULL, "singleton == null");
	_tmp1_ = bird_font_test_cases_new ();
	_bird_font_test_cases_unref0 (self->priv->tests);
	self->priv->tests = _tmp1_;
	_tmp2_ = self->priv->tests;
	_tmp3_ = bird_font_test_cases_get_test_functions (_tmp2_);
	self->priv->test_cases = _tmp3_;
	_tmp4_ = self->priv->test_cases;
	_tmp5_ = g_list_first (_tmp4_);
	self->priv->current_case = _tmp5_;
	_tmp6_ = g_strdup ("All");
	_g_free0 (self->test_cases_to_run);
	self->test_cases_to_run = _tmp6_;
	bird_font_test_bird_font_from_command_line (self);
	return self;
}

BirdFontTestBirdFont*
bird_font_test_bird_font_new (void)
{
	return bird_font_test_bird_font_construct (BIRD_FONT_TYPE_TEST_BIRD_FONT);
}

gboolean
bird_font_test_bird_font_is_slow_test (void)
{
	gboolean result;
	result = bird_font_test_bird_font_slow_test;
	return result;
}

void
bird_font_test_bird_font_set_slow_test (gboolean s)
{
	bird_font_test_bird_font_slow_test = s;
}

void
bird_font_test_bird_font_run_tests (void)
{
	BirdFontTestBirdFont* t = NULL;
	BirdFontTestBirdFont* _tmp0_;
	_tmp0_ = bird_font_test_bird_font_get_singleton ();
	t = _tmp0_;
	bird_font_test_bird_font_state = BIRD_FONT_TEST_BIRD_FONT_RUNNING;
	bird_font_test_bird_font_run_all_tests (t);
	_g_object_unref0 (t);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

BirdFontTestBirdFont*
bird_font_test_bird_font_get_singleton (void)
{
	BirdFontTestBirdFont* _tmp0_;
	BirdFontTestBirdFont* _tmp2_;
	BirdFontTestBirdFont* _tmp3_;
	BirdFontTestBirdFont* result;
	_tmp0_ = bird_font_test_bird_font_singleton;
	if (_tmp0_ == NULL) {
		BirdFontTestBirdFont* _tmp1_;
		_tmp1_ = bird_font_test_bird_font_new ();
		_g_object_unref0 (bird_font_test_bird_font_singleton);
		bird_font_test_bird_font_singleton = _tmp1_;
	}
	_tmp2_ = bird_font_test_bird_font_singleton;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, BIRD_FONT_TYPE_TEST_BIRD_FONT, BirdFontTestBirdFont));
	result = _tmp3_;
	return result;
}

static gboolean
bird_font_test_bird_font_has_test_case (BirdFontTestBirdFont* self,
                                        const gchar* s)
{
	GList* _tmp0_;
	gboolean _tmp4_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (s != NULL, FALSE);
	_tmp0_ = self->priv->test_cases;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp0_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			BirdFontTest* _tmp1_;
			BirdFontTest* t = NULL;
			_tmp1_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
			t = _tmp1_;
			{
				BirdFontTest* _tmp2_;
				const gchar* _tmp3_;
				_tmp2_ = t;
				_tmp3_ = _tmp2_->name;
				if (g_strcmp0 (_tmp3_, s) == 0) {
					result = TRUE;
					_g_object_unref0 (t);
					return result;
				}
				_g_object_unref0 (t);
			}
		}
	}
	if (g_strcmp0 (s, "") == 0) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = g_strcmp0 (s, "All") == 0;
	}
	result = _tmp4_;
	return result;
}

/** Run only test specified on the command line. */
static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
bird_font_test_bird_font_from_command_line (BirdFontTestBirdFont* self)
{
	gchar* stn = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_bird_font_get_argument ("--test");
	stn = _tmp0_;
	_tmp1_ = stn;
	if (_tmp1_ != NULL) {
		gchar* st = NULL;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		const gchar* _tmp4_;
		gboolean _tmp17_ = FALSE;
		const gchar* _tmp18_;
		const gchar* _tmp25_;
		gchar* _tmp26_;
		_tmp2_ = stn;
		_tmp3_ = g_strdup ((const gchar*) _tmp2_);
		st = _tmp3_;
		_tmp4_ = st;
		if (!bird_font_test_bird_font_has_test_case (self, _tmp4_)) {
			FILE* _tmp5_;
			const gchar* _tmp6_;
			const gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			FILE* _tmp10_;
			GList* _tmp11_;
			_tmp5_ = stderr;
			_tmp6_ = st;
			_tmp7_ = string_to_string (_tmp6_);
			_tmp8_ = g_strconcat ("Test case \"", _tmp7_, "\" does not exist.\n", NULL);
			_tmp9_ = _tmp8_;
			fprintf (_tmp5_, "%s", _tmp9_);
			_g_free0 (_tmp9_);
			_tmp10_ = stderr;
			fprintf (_tmp10_, "\nAvailable test cases:\n");
			_tmp11_ = self->priv->test_cases;
			{
				GList* t_collection = NULL;
				GList* t_it = NULL;
				t_collection = _tmp11_;
				for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
					BirdFontTest* _tmp12_;
					BirdFontTest* t = NULL;
					_tmp12_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
					t = _tmp12_;
					{
						FILE* _tmp13_;
						BirdFontTest* _tmp14_;
						const gchar* _tmp15_;
						FILE* _tmp16_;
						_tmp13_ = stderr;
						_tmp14_ = t;
						_tmp15_ = _tmp14_->name;
						fprintf (_tmp13_, "%s", _tmp15_);
						_tmp16_ = stderr;
						fprintf (_tmp16_, "\n");
						_g_object_unref0 (t);
					}
				}
			}
			exit (1);
		}
		_tmp18_ = st;
		if (g_strcmp0 (_tmp18_, "All") == 0) {
			_tmp17_ = TRUE;
		} else {
			const gchar* _tmp19_;
			_tmp19_ = st;
			_tmp17_ = g_strcmp0 (_tmp19_, "") == 0;
		}
		if (_tmp17_) {
			_g_free0 (st);
			_g_free0 (stn);
			return;
		} else {
			FILE* _tmp20_;
			const gchar* _tmp21_;
			const gchar* _tmp22_;
			gchar* _tmp23_;
			gchar* _tmp24_;
			_tmp20_ = stderr;
			_tmp21_ = st;
			_tmp22_ = string_to_string (_tmp21_);
			_tmp23_ = g_strconcat ("Run test case \"", _tmp22_, "\" \n", NULL);
			_tmp24_ = _tmp23_;
			fprintf (_tmp20_, "%s", _tmp24_);
			_g_free0 (_tmp24_);
		}
		_tmp25_ = st;
		_tmp26_ = g_strdup (_tmp25_);
		_g_free0 (self->test_cases_to_run);
		self->test_cases_to_run = _tmp26_;
		_g_free0 (st);
	}
	_g_free0 (stn);
}

void
bird_font_test_bird_font_log (const gchar* log_domain,
                              GLogLevelFlags log_levels,
                              const gchar* message)
{
	BirdFontTest* t = NULL;
	BirdFontTestBirdFont* _tmp0_;
	BirdFontTestBirdFont* _tmp1_;
	GList* _tmp2_;
	gconstpointer _tmp3_;
	BirdFontTest* _tmp4_;
	BirdFontTest* _tmp5_;
	FILE* _tmp7_;
	BirdFontTest* _tmp8_;
	const gchar* _tmp9_;
	FILE* _tmp10_;
	BirdFontTestBirdFont* _tmp11_;
	BirdFontTestBirdFont* _tmp12_;
	g_return_if_fail (message != NULL);
	_tmp0_ = bird_font_test_bird_font_get_singleton ();
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->priv->current_case;
	_tmp3_ = ((GList*) _tmp2_)->data;
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST ((BirdFontTest*) _tmp3_, BIRD_FONT_TYPE_TEST, BirdFontTest));
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp1_);
	t = _tmp5_;
	if (log_domain != NULL) {
		FILE* _tmp6_;
		_tmp6_ = stderr;
		fprintf (_tmp6_, "%s: \n", (const gchar*) log_domain);
	}
	_tmp7_ = stderr;
	_tmp8_ = t;
	_tmp9_ = _tmp8_->name;
	fprintf (_tmp7_, "Testcase \"%s\" failed because:\n", _tmp9_);
	_tmp10_ = stderr;
	fprintf (_tmp10_, "%s\n\n", message);
	_tmp11_ = bird_font_test_bird_font_get_singleton ();
	_tmp12_ = _tmp11_;
	_tmp12_->priv->has_failed = TRUE;
	_g_object_unref0 (_tmp12_);
	_vala_assert (!bird_font_bird_font_fatal_wanings, "!BirdFont.fatal_wanings");
	_g_object_unref0 (t);
}

static void
_bird_font_test_bird_font_log_glog_func (const gchar* log_domain,
                                         GLogLevelFlags log_levels,
                                         const gchar* message,
                                         gpointer self)
{
	bird_font_test_bird_font_log (log_domain, log_levels, message);
}

void
bird_font_test_bird_font_continue (void)
{
	gint s = 0;
	gint _tmp0_;
	BirdFontTestBirdFont* t = NULL;
	BirdFontTestBirdFont* _tmp1_;
	GLogLevelFlags levels = 0U;
	_tmp0_ = g_atomic_int_get ((volatile gint *) (&bird_font_test_bird_font_state));
	s = _tmp0_;
	if (s == BIRD_FONT_TEST_BIRD_FONT_DONE) {
		_g_object_unref0 (bird_font_test_bird_font_singleton);
		bird_font_test_bird_font_singleton = NULL;
	}
	_tmp1_ = bird_font_test_bird_font_get_singleton ();
	t = _tmp1_;
	levels = (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL) | G_LOG_LEVEL_WARNING;
	g_log_set_handler (NULL, levels, _bird_font_test_bird_font_log_glog_func, NULL);
	g_atomic_int_set ((volatile gint *) (&bird_font_test_bird_font_state), BIRD_FONT_TEST_BIRD_FONT_RUNNING);
	bird_font_test_bird_font_run_all_tests (t);
	_g_object_unref0 (t);
}

gboolean
bird_font_test_bird_font_is_running (void)
{
	gint r = 0;
	gint _tmp0_;
	gboolean result;
	_tmp0_ = g_atomic_int_get ((volatile gint *) (&bird_font_test_bird_font_state));
	r = _tmp0_;
	result = r == BIRD_FONT_TEST_BIRD_FONT_RUNNING;
	return result;
}

void
bird_font_test_bird_font_pause (void)
{
	GLogFunc _tmp0_;
	gpointer _tmp0__target;
	g_atomic_int_set ((volatile gint *) (&bird_font_test_bird_font_state), BIRD_FONT_TEST_BIRD_FONT_PAUSED);
	_tmp0_ = g_log_default_handler;
	_tmp0__target = NULL;
	g_log_set_handler (NULL, G_LOG_LEVEL_MASK, _tmp0_, _tmp0__target);
}

static void
bird_font_test_bird_font_pad (gint t)
{
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				FILE* _tmp2_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < t)) {
					break;
				}
				_tmp2_ = stdout;
				fprintf (_tmp2_, " ");
			}
		}
	}
}

static gchar*
double_to_string (gdouble self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_tmp2_ = g_ascii_dtostr (_tmp1_, (gint) G_ASCII_DTOSTR_BUF_SIZE, self);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp1_ = (g_free (_tmp1_), NULL);
	result = _tmp4_;
	return result;
}

void
bird_font_test_bird_font_print_result (BirdFontTestBirdFont* self)
{
	FILE* _tmp0_;
	FILE* _tmp1_;
	GList* _tmp2_;
	GList* _tmp10_;
	GList* _tmp12_;
	GList* _tmp20_;
	GList* _tmp28_;
	FILE* _tmp41_;
	FILE* _tmp42_;
	GList* _tmp43_;
	GList* _tmp44_;
	GList* _tmp45_;
	GList* _tmp46_;
	g_return_if_fail (self != NULL);
	_tmp0_ = stdout;
	fprintf (_tmp0_, "\n");
	_tmp1_ = stdout;
	fprintf (_tmp1_, "Test case results:\n");
	_tmp2_ = self->priv->skipped;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp2_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			BirdFontTest* _tmp3_;
			BirdFontTest* t = NULL;
			_tmp3_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
			t = _tmp3_;
			{
				FILE* _tmp4_;
				BirdFontTest* _tmp5_;
				const gchar* _tmp6_;
				BirdFontTest* _tmp7_;
				const gchar* _tmp8_;
				FILE* _tmp9_;
				_tmp4_ = stdout;
				_tmp5_ = t;
				_tmp6_ = _tmp5_->name;
				fprintf (_tmp4_, "%s", _tmp6_);
				_tmp7_ = t;
				_tmp8_ = _tmp7_->name;
				bird_font_test_bird_font_pad (40 - g_utf8_strlen (_tmp8_, (gssize) -1));
				_tmp9_ = stdout;
				fprintf (_tmp9_, "Skipped\n");
				_g_object_unref0 (t);
			}
		}
	}
	_tmp10_ = self->priv->skipped;
	if (g_list_length (_tmp10_) > ((guint) 0)) {
		FILE* _tmp11_;
		_tmp11_ = stdout;
		fprintf (_tmp11_, "\n");
	}
	_tmp12_ = self->priv->passed;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp12_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			BirdFontTest* _tmp13_;
			BirdFontTest* t = NULL;
			_tmp13_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
			t = _tmp13_;
			{
				FILE* _tmp14_;
				BirdFontTest* _tmp15_;
				const gchar* _tmp16_;
				BirdFontTest* _tmp17_;
				const gchar* _tmp18_;
				FILE* _tmp19_;
				_tmp14_ = stdout;
				_tmp15_ = t;
				_tmp16_ = _tmp15_->name;
				fprintf (_tmp14_, "%s", _tmp16_);
				_tmp17_ = t;
				_tmp18_ = _tmp17_->name;
				bird_font_test_bird_font_pad (40 - g_utf8_strlen (_tmp18_, (gssize) -1));
				_tmp19_ = stdout;
				fprintf (_tmp19_, "Passed\n");
				_g_object_unref0 (t);
			}
		}
	}
	_tmp20_ = self->priv->failed;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp20_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			BirdFontTest* _tmp21_;
			BirdFontTest* t = NULL;
			_tmp21_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
			t = _tmp21_;
			{
				FILE* _tmp22_;
				BirdFontTest* _tmp23_;
				const gchar* _tmp24_;
				BirdFontTest* _tmp25_;
				const gchar* _tmp26_;
				FILE* _tmp27_;
				_tmp22_ = stdout;
				_tmp23_ = t;
				_tmp24_ = _tmp23_->name;
				fprintf (_tmp22_, "%s", _tmp24_);
				_tmp25_ = t;
				_tmp26_ = _tmp25_->name;
				bird_font_test_bird_font_pad (40 - g_utf8_strlen (_tmp26_, (gssize) -1));
				_tmp27_ = stdout;
				fprintf (_tmp27_, "Failed\n");
				_g_object_unref0 (t);
			}
		}
	}
	_tmp28_ = self->priv->bechmarks;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp28_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			BirdFontTest* _tmp29_;
			BirdFontTest* t = NULL;
			_tmp29_ = _g_object_ref0 ((BirdFontTest*) t_it->data);
			t = _tmp29_;
			{
				FILE* _tmp30_;
				BirdFontTest* _tmp31_;
				const gchar* _tmp32_;
				BirdFontTest* _tmp33_;
				const gchar* _tmp34_;
				FILE* _tmp35_;
				BirdFontTest* _tmp36_;
				gchar* _tmp37_;
				gchar* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				_tmp30_ = stdout;
				_tmp31_ = t;
				_tmp32_ = _tmp31_->name;
				fprintf (_tmp30_, "%s", _tmp32_);
				_tmp33_ = t;
				_tmp34_ = _tmp33_->name;
				bird_font_test_bird_font_pad (40 - g_utf8_strlen (_tmp34_, (gssize) -1));
				_tmp35_ = stdout;
				_tmp36_ = t;
				_tmp37_ = double_to_string (bird_font_test_get_time (_tmp36_));
				_tmp38_ = _tmp37_;
				_tmp39_ = g_strconcat (_tmp38_, "s\n", NULL);
				_tmp40_ = _tmp39_;
				fprintf (_tmp35_, "%s", _tmp40_);
				_g_free0 (_tmp40_);
				_g_free0 (_tmp38_);
				_g_object_unref0 (t);
			}
		}
	}
	_tmp41_ = stdout;
	fprintf (_tmp41_, "\n");
	_tmp42_ = stdout;
	_tmp43_ = self->priv->passed;
	_tmp44_ = self->priv->failed;
	_tmp45_ = self->priv->passed;
	_tmp46_ = self->priv->failed;
	fprintf (_tmp42_, "Total %u test cases executed, %u passed and %u failed.\n", g_list_length (_tmp43_) + g_list_length (_tmp44_), g_list_length (_tmp45_), g_list_length (_tmp46_));
}

/** Run tests in main loop. */
static gboolean
__lambda220_ (BirdFontTestBirdFont* self)
{
	gint s = 0;
	gint _tmp0_;
	gboolean _tmp1_ = FALSE;
	BirdFontTest* test = NULL;
	GList* _tmp3_;
	gconstpointer _tmp4_;
	BirdFontTest* _tmp5_;
	gboolean _tmp6_ = FALSE;
	const gchar* _tmp7_;
	BirdFontTest* _tmp18_;
	GList* _tmp27_;
	GList* _tmp28_;
	GList* _tmp29_;
	GList* _tmp34_;
	GList* _tmp35_;
	gboolean result;
	_tmp0_ = g_atomic_int_get ((volatile gint *) (&bird_font_test_bird_font_state));
	s = _tmp0_;
	if (s != BIRD_FONT_TEST_BIRD_FONT_RUNNING) {
		_tmp1_ = TRUE;
	} else {
		GList* _tmp2_;
		_tmp2_ = self->priv->current_case;
		_tmp1_ = _tmp2_ == NULL;
	}
	if (_tmp1_) {
		result = FALSE;
		return result;
	}
	_tmp3_ = self->priv->current_case;
	_tmp4_ = ((GList*) _tmp3_)->data;
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST ((BirdFontTest*) _tmp4_, BIRD_FONT_TYPE_TEST, BirdFontTest));
	test = _tmp5_;
	self->priv->has_failed = FALSE;
	self->priv->has_skipped = FALSE;
	_tmp7_ = self->test_cases_to_run;
	if (g_strcmp0 (_tmp7_, "All") != 0) {
		const gchar* _tmp8_;
		BirdFontTest* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = self->test_cases_to_run;
		_tmp9_ = test;
		_tmp10_ = _tmp9_->name;
		_tmp6_ = g_strcmp0 (_tmp8_, _tmp10_) != 0;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		self->priv->has_skipped = TRUE;
	} else {
		BirdFontTest* _tmp11_;
		_tmp11_ = test;
		if (bird_font_test_is_benchmark (_tmp11_)) {
			BirdFontTest* _tmp12_;
			BirdFontTest* _tmp13_;
			GCallback _tmp14_;
			BirdFontTest* _tmp15_;
			_tmp12_ = test;
			bird_font_test_timer_start (_tmp12_);
			_tmp13_ = test;
			_tmp14_ = _tmp13_->callback;
			_tmp14_ ();
			_tmp15_ = test;
			bird_font_test_print (_tmp15_);
		} else {
			BirdFontTest* _tmp16_;
			GCallback _tmp17_;
			_tmp16_ = test;
			_tmp17_ = _tmp16_->callback;
			_tmp17_ ();
		}
	}
	_tmp18_ = test;
	if (bird_font_test_is_benchmark (_tmp18_)) {
		BirdFontTest* _tmp19_;
		BirdFontTest* _tmp20_;
		_tmp19_ = test;
		_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, BIRD_FONT_TYPE_TEST, BirdFontTest));
		self->priv->bechmarks = g_list_append (self->priv->bechmarks, _tmp20_);
	} else {
		if (self->priv->has_failed) {
			BirdFontTest* _tmp21_;
			BirdFontTest* _tmp22_;
			_tmp21_ = test;
			_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, BIRD_FONT_TYPE_TEST, BirdFontTest));
			self->priv->failed = g_list_append (self->priv->failed, _tmp22_);
			if (bird_font_bird_font_has_argument ("--exit")) {
				bird_font_test_bird_font_print_result (self);
				exit (1);
			}
		} else {
			if (self->priv->has_skipped) {
				BirdFontTest* _tmp23_;
				BirdFontTest* _tmp24_;
				_tmp23_ = test;
				_tmp24_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, BIRD_FONT_TYPE_TEST, BirdFontTest));
				self->priv->skipped = g_list_append (self->priv->skipped, _tmp24_);
			} else {
				BirdFontTest* _tmp25_;
				BirdFontTest* _tmp26_;
				_tmp25_ = test;
				_tmp26_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, BIRD_FONT_TYPE_TEST, BirdFontTest));
				self->priv->passed = g_list_append (self->priv->passed, _tmp26_);
			}
		}
	}
	_tmp27_ = self->priv->current_case;
	_tmp28_ = self->priv->test_cases;
	_tmp29_ = g_list_last (_tmp28_);
	if (G_UNLIKELY (_tmp27_ == _tmp29_)) {
		FILE* _tmp30_;
		GLogFunc _tmp31_;
		gpointer _tmp31__target;
		_tmp30_ = stdout;
		fprintf (_tmp30_, "Finished running test suite.\n");
		g_atomic_int_set ((volatile gint *) (&bird_font_test_bird_font_state), BIRD_FONT_TEST_BIRD_FONT_DONE);
		_tmp31_ = g_log_default_handler;
		_tmp31__target = NULL;
		g_log_set_handler (NULL, G_LOG_LEVEL_MASK, _tmp31_, _tmp31__target);
		bird_font_test_bird_font_print_result (self);
		if (bird_font_bird_font_has_argument ("--exit")) {
			gint _tmp32_ = 0;
			GList* _tmp33_;
			bird_font_test_bird_font_print_result (self);
			_tmp33_ = self->priv->failed;
			if (g_list_length (_tmp33_) == ((guint) 0)) {
				_tmp32_ = 0;
			} else {
				_tmp32_ = 1;
			}
			exit (_tmp32_);
		}
		result = FALSE;
		_g_object_unref0 (test);
		return result;
	}
	_tmp34_ = self->priv->current_case;
	_tmp35_ = ((GList*) _tmp34_)->next;
	self->priv->current_case = _tmp35_;
	result = TRUE;
	_g_object_unref0 (test);
	return result;
}

static gboolean
___lambda220__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda220_ ((BirdFontTestBirdFont*) self);
	return result;
}

void
bird_font_test_bird_font_run_all_tests (BirdFontTestBirdFont* self)
{
	GSource* idle = NULL;
	GSource* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_timeout_source_new ((guint) 20);
	idle = _tmp0_;
	g_source_set_callback (idle, ___lambda220__gsource_func, g_object_ref (self), g_object_unref);
	g_source_attach (idle, NULL);
	_g_source_unref0 (idle);
}

static void
bird_font_test_bird_font_class_init (BirdFontTestBirdFontClass * klass,
                                     gpointer klass_data)
{
	bird_font_test_bird_font_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontTestBirdFont_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_test_bird_font_finalize;
}

static void
bird_font_test_bird_font_instance_init (BirdFontTestBirdFont * self,
                                        gpointer klass)
{
	self->priv = bird_font_test_bird_font_get_instance_private (self);
	self->priv->current_case = NULL;
	self->priv->has_failed = FALSE;
	self->priv->has_skipped = FALSE;
}

static void
bird_font_test_bird_font_finalize (GObject * obj)
{
	BirdFontTestBirdFont * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TEST_BIRD_FONT, BirdFontTestBirdFont);
	_bird_font_test_cases_unref0 (self->priv->tests);
	(self->priv->passed == NULL) ? NULL : (self->priv->passed = (_g_list_free__g_object_unref0_ (self->priv->passed), NULL));
	(self->priv->failed == NULL) ? NULL : (self->priv->failed = (_g_list_free__g_object_unref0_ (self->priv->failed), NULL));
	(self->priv->skipped == NULL) ? NULL : (self->priv->skipped = (_g_list_free__g_object_unref0_ (self->priv->skipped), NULL));
	(self->priv->bechmarks == NULL) ? NULL : (self->priv->bechmarks = (_g_list_free__g_object_unref0_ (self->priv->bechmarks), NULL));
	_g_free0 (self->test_cases_to_run);
	G_OBJECT_CLASS (bird_font_test_bird_font_parent_class)->finalize (obj);
}

/** Class for executing tests cases. */
static GType
bird_font_test_bird_font_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontTestBirdFontClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_test_bird_font_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontTestBirdFont), 0, (GInstanceInitFunc) bird_font_test_bird_font_instance_init, NULL };
	GType bird_font_test_bird_font_type_id;
	bird_font_test_bird_font_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontTestBirdFont", &g_define_type_info, 0);
	BirdFontTestBirdFont_private_offset = g_type_add_instance_private (bird_font_test_bird_font_type_id, sizeof (BirdFontTestBirdFontPrivate));
	return bird_font_test_bird_font_type_id;
}

GType
bird_font_test_bird_font_get_type (void)
{
	static volatile gsize bird_font_test_bird_font_type_id__once = 0;
	if (g_once_init_enter (&bird_font_test_bird_font_type_id__once)) {
		GType bird_font_test_bird_font_type_id;
		bird_font_test_bird_font_type_id = bird_font_test_bird_font_get_type_once ();
		g_once_init_leave (&bird_font_test_bird_font_type_id__once, bird_font_test_bird_font_type_id);
	}
	return bird_font_test_bird_font_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

