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

/* 
 * File Name: 
 * Creation Date: 
 * Last Modified: 
 *
 * Authored by Frederik 'playya' Sdun <Frederik.Sdun@googlemail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 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 General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

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

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))



void test_string (void);
void test_string_padding (void);
void test_align (void);
void test_set (void);
void _vala_main (gchar** args, int args_length1);
static void _test_set_gcallback (void);
static void _test_align_gcallback (void);
static void _test_string_padding_gcallback (void);
static void _test_string_gcallback (void);


void test_string (void) {
	FsoFrameworkBinBuilder* _tmp0_;
	FsoFrameworkBinBuilder* bin;
	gchar* _tmp1_;
	gchar* s;
	gint _tmp2_;
	gint _tmp3_;
	guint _tmp4_;
	guint _tmp5_;
	_tmp0_ = fso_framework_bin_builder_new (0, (guint8) '\0', G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN);
	bin = _tmp0_;
	_tmp1_ = g_strdup ("HEllo World");
	s = _tmp1_;
	fso_framework_bin_builder_append_string (bin, s, TRUE, 0, (guint8) '\0');
	_tmp2_ = strlen (s);
	_tmp3_ = _tmp2_;
	_tmp4_ = fso_framework_bin_builder_get_length (bin);
	_tmp5_ = _tmp4_;
	g_assert (((guint) (_tmp3_ + 1)) == _tmp5_);
	_g_free0 (s);
	_g_object_unref0 (bin);
}


void test_string_padding (void) {
	FsoFrameworkBinBuilder* _tmp0_;
	FsoFrameworkBinBuilder* bin;
	guint _tmp1_;
	guint _tmp2_;
	_tmp0_ = fso_framework_bin_builder_new (0, (guint8) '\0', G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN);
	bin = _tmp0_;
	fso_framework_bin_builder_append_string (bin, "HELLO WORLD", TRUE, 20, (guint8) ' ');
	_tmp1_ = fso_framework_bin_builder_get_length (bin);
	_tmp2_ = _tmp1_;
	g_assert (_tmp2_ == ((guint) 20));
	_g_object_unref0 (bin);
}


void test_align (void) {
	FsoFrameworkBinBuilder* _tmp0_;
	FsoFrameworkBinBuilder* bin;
	guint _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	guint _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	guint _tmp7_;
	guint _tmp8_;
	guint _tmp9_;
	guint _tmp10_;
	guint8* _tmp11_ = NULL;
	guint8* _tmp12_;
	gint _tmp12__length1;
	guint _tmp13_;
	guint _tmp14_;
	_tmp0_ = fso_framework_bin_builder_new (4, (guint8) ' ', G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN);
	bin = _tmp0_;
	fso_framework_bin_builder_append_uint8 (bin, (guint8) 'H');
	_tmp1_ = fso_framework_bin_builder_get_length (bin);
	_tmp2_ = _tmp1_;
	g_assert ((_tmp2_ % 4) == ((guint) 0));
	fso_framework_bin_builder_append_uint16 (bin, (guint16) 42);
	_tmp3_ = fso_framework_bin_builder_get_length (bin);
	_tmp4_ = _tmp3_;
	g_assert ((_tmp4_ % 4) == ((guint) 0));
	fso_framework_bin_builder_append_uint32 (bin, (guint32) 0xFFFFFFFFLL);
	_tmp5_ = fso_framework_bin_builder_get_length (bin);
	_tmp6_ = _tmp5_;
	g_assert ((_tmp6_ % 4) == ((guint) 0));
	fso_framework_bin_builder_append_uint64 (bin, (guint64) 0x1111111111111111LL);
	_tmp7_ = fso_framework_bin_builder_get_length (bin);
	_tmp8_ = _tmp7_;
	g_assert ((_tmp8_ % 4) == ((guint) 0));
	fso_framework_bin_builder_append_string (bin, "hallo welt", TRUE, 0, (guint8) '\0');
	_tmp9_ = fso_framework_bin_builder_get_length (bin);
	_tmp10_ = _tmp9_;
	g_assert ((_tmp10_ % 4) == ((guint) 0));
	_tmp11_ = g_new0 (guint8, 3);
	_tmp11_[0] = (guint8) 0x11;
	_tmp11_[1] = (guint8) 0x22;
	_tmp11_[2] = (guint8) 0x33;
	_tmp12_ = _tmp11_;
	_tmp12__length1 = 3;
	fso_framework_bin_builder_append_data (bin, _tmp12_, 3, 0, (guint8) '\0');
	_tmp12_ = (g_free (_tmp12_), NULL);
	_tmp13_ = fso_framework_bin_builder_get_length (bin);
	_tmp14_ = _tmp13_;
	g_assert ((_tmp14_ % 4) == ((guint) 0));
	_g_object_unref0 (bin);
}


void test_set (void) {
	FsoFrameworkBinBuilder* _tmp0_;
	FsoFrameworkBinBuilder* bin;
	guint _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	guint _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	_tmp0_ = fso_framework_bin_builder_new (0, (guint8) '\0', G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN);
	bin = _tmp0_;
	fso_framework_bin_builder_set_uint8 (bin, (guint8) 10, 100);
	_tmp1_ = fso_framework_bin_builder_get_length (bin);
	_tmp2_ = _tmp1_;
	g_assert (_tmp2_ == ((guint) 101));
	fso_framework_bin_builder_set_uint64 (bin, (guint64) 0xFFFF, 10);
	_tmp3_ = fso_framework_bin_builder_get_length (bin);
	_tmp4_ = _tmp3_;
	g_assert (_tmp4_ == ((guint) 101));
	fso_framework_bin_builder_set_uint32 (bin, (guint32) 11, 100);
	_tmp5_ = fso_framework_bin_builder_get_length (bin);
	_tmp6_ = _tmp5_;
	g_assert (_tmp6_ == ((guint) 104));
	_g_object_unref0 (bin);
}


static void _test_set_gcallback (void) {
	test_set ();
}


static void _test_align_gcallback (void) {
	test_align ();
}


static void _test_string_padding_gcallback (void) {
	test_string_padding ();
}


static void _test_string_gcallback (void) {
	test_string ();
}


void _vala_main (gchar** args, int args_length1) {
	g_test_init (&args_length1, &args, NULL);
	g_test_add_func ("/FsoFramework.BinBuilder/Set", _test_set_gcallback);
	g_test_add_func ("/FsoFramework.BinBuilder/Align", _test_align_gcallback);
	g_test_add_func ("/FsoFramework.BinBuilder/Padding", _test_string_padding_gcallback);
	g_test_add_func ("/FsoFramework.BinBuilder/Strings", _test_string_gcallback);
	g_test_run ();
}


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



