/* test-prefix-stream.c generated by valac 0.56.18, the Vala compiler
 * generated from test-prefix-stream.vala, do not modify */

/* Tests for PrefixInputStream.*/
/**/
/* © 2025 Alistair Turnbull <apt1002@mupsych.org>*/
/**/
/* 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 3, 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, see <https://www.gnu.org/licenses/>.*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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 TYPE_GEE_TEST_CASE (gee_test_case_get_type ())
#define GEE_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GEE_TEST_CASE, GeeTestCase))
#define GEE_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GEE_TEST_CASE, GeeTestCaseClass))
#define IS_GEE_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GEE_TEST_CASE))
#define IS_GEE_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GEE_TEST_CASE))
#define GEE_TEST_CASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GEE_TEST_CASE, GeeTestCaseClass))

typedef struct _GeeTestCase GeeTestCase;
typedef struct _GeeTestCaseClass GeeTestCaseClass;
typedef struct _GeeTestCasePrivate GeeTestCasePrivate;

#define TYPE_PREFIX_STREAM_TESTS (prefix_stream_tests_get_type ())
#define PREFIX_STREAM_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFIX_STREAM_TESTS, PrefixStreamTests))
#define PREFIX_STREAM_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFIX_STREAM_TESTS, PrefixStreamTestsClass))
#define IS_PREFIX_STREAM_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFIX_STREAM_TESTS))
#define IS_PREFIX_STREAM_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFIX_STREAM_TESTS))
#define PREFIX_STREAM_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFIX_STREAM_TESTS, PrefixStreamTestsClass))

typedef struct _PrefixStreamTests PrefixStreamTests;
typedef struct _PrefixStreamTestsClass PrefixStreamTestsClass;
typedef struct _PrefixStreamTestsPrivate PrefixStreamTestsPrivate;
enum  {
	PREFIX_STREAM_TESTS_0_PROPERTY,
	PREFIX_STREAM_TESTS_NUM_PROPERTIES
};
static GParamSpec* prefix_stream_tests_properties[PREFIX_STREAM_TESTS_NUM_PROPERTIES];
typedef void (*GeeTestCaseTestMethod) (gpointer user_data);

#define TYPE_PREFIX_INPUT_STREAM (prefix_input_stream_get_type ())
#define PREFIX_INPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFIX_INPUT_STREAM, PrefixInputStream))
#define PREFIX_INPUT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFIX_INPUT_STREAM, PrefixInputStreamClass))
#define IS_PREFIX_INPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFIX_INPUT_STREAM))
#define IS_PREFIX_INPUT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFIX_INPUT_STREAM))
#define PREFIX_INPUT_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFIX_INPUT_STREAM, PrefixInputStreamClass))

typedef struct _PrefixInputStream PrefixInputStream;
typedef struct _PrefixInputStreamClass PrefixInputStreamClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GeeTestCase {
	GObject parent_instance;
	GeeTestCasePrivate * priv;
};

struct _GeeTestCaseClass {
	GObjectClass parent_class;
	void (*set_up) (GeeTestCase* self);
	void (*tear_down) (GeeTestCase* self);
};

struct _PrefixStreamTests {
	GeeTestCase parent_instance;
	PrefixStreamTestsPrivate * priv;
};

struct _PrefixStreamTestsClass {
	GeeTestCaseClass parent_class;
};

static gpointer prefix_stream_tests_parent_class = NULL;

VALA_EXTERN GType gee_test_case_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeTestCase, g_object_unref)
VALA_EXTERN GType prefix_stream_tests_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PrefixStreamTests, g_object_unref)
VALA_EXTERN PrefixStreamTests* prefix_stream_tests_new (void);
VALA_EXTERN PrefixStreamTests* prefix_stream_tests_construct (GType object_type);
VALA_EXTERN GeeTestCase* gee_test_case_construct (GType object_type,
                                      const gchar* name);
VALA_EXTERN void gee_test_case_add_test (GeeTestCase* self,
                             const gchar* name,
                             GeeTestCaseTestMethod test,
                             gpointer test_target,
                             GDestroyNotify test_target_destroy_notify);
static void prefix_stream_tests_basic_test (PrefixStreamTests* self);
static void _prefix_stream_tests_basic_test_gee_test_case_test_method (gpointer self);
static guint8* _vala_array_dup1 (guint8* self,
                          gssize length);
VALA_EXTERN GType prefix_input_stream_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PrefixInputStream, g_object_unref)
VALA_EXTERN PrefixInputStream* prefix_input_stream_new (guint8* prefix,
                                            gint prefix_length1,
                                            GInputStream* base_stream);
VALA_EXTERN PrefixInputStream* prefix_input_stream_construct (GType object_type,
                                                  guint8* prefix,
                                                  gint prefix_length1,
                                                  GInputStream* base_stream);
static GType prefix_stream_tests_get_type_once (void);
static gint _vala_main (gchar** args,
                 gint args_length1);
VALA_EXTERN GTestSuite* gee_test_case_get_suite (GeeTestCase* self);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
_prefix_stream_tests_basic_test_gee_test_case_test_method (gpointer self)
{
#line 23 "test-prefix-stream.vala"
	prefix_stream_tests_basic_test ((PrefixStreamTests*) self);
#line 145 "test-prefix-stream.c"
}

PrefixStreamTests*
prefix_stream_tests_construct (GType object_type)
{
	PrefixStreamTests * self = NULL;
#line 22 "test-prefix-stream.vala"
	self = (PrefixStreamTests*) gee_test_case_construct (object_type, "PrefixStreamTests");
#line 23 "test-prefix-stream.vala"
	gee_test_case_add_test ((GeeTestCase*) self, "basic_test", _prefix_stream_tests_basic_test_gee_test_case_test_method, g_object_ref (self), g_object_unref);
#line 21 "test-prefix-stream.vala"
	return self;
#line 158 "test-prefix-stream.c"
}

PrefixStreamTests*
prefix_stream_tests_new (void)
{
#line 21 "test-prefix-stream.vala"
	return prefix_stream_tests_construct (TYPE_PREFIX_STREAM_TESTS);
#line 166 "test-prefix-stream.c"
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
#line 1609 "glib-2.0.vapi"
	g_return_val_if_fail (self != NULL, NULL);
#line 1610 "glib-2.0.vapi"
	res = (guint8*) self;
#line 1610 "glib-2.0.vapi"
	res_length1 = -1;
#line 1610 "glib-2.0.vapi"
	_res_size_ = res_length1;
#line 1611 "glib-2.0.vapi"
	_tmp0_ = strlen (self);
#line 1611 "glib-2.0.vapi"
	_tmp1_ = _tmp0_;
#line 1611 "glib-2.0.vapi"
	res_length1 = (gint) _tmp1_;
#line 1612 "glib-2.0.vapi"
	_tmp2_ = res;
#line 1612 "glib-2.0.vapi"
	_tmp2__length1 = res_length1;
#line 1612 "glib-2.0.vapi"
	if (result_length1) {
#line 1612 "glib-2.0.vapi"
		*result_length1 = _tmp2__length1;
#line 203 "test-prefix-stream.c"
	}
#line 1612 "glib-2.0.vapi"
	result = _tmp2_;
#line 1612 "glib-2.0.vapi"
	return result;
#line 209 "test-prefix-stream.c"
}

static guint8*
_vala_array_dup1 (guint8* self,
                  gssize length)
{
#line 27 "test-prefix-stream.vala"
	if (length > 0) {
#line 27 "test-prefix-stream.vala"
		return _vala_memdup2 (self, length * sizeof (guint8));
#line 220 "test-prefix-stream.c"
	}
#line 27 "test-prefix-stream.vala"
	return NULL;
#line 224 "test-prefix-stream.c"
}

static void
prefix_stream_tests_basic_test (PrefixStreamTests* self)
{
	GInputStream* input = NULL;
	guint8* _tmp0_;
	gint _tmp0__length1;
	gint _tmp1_ = 0;
	guint8* _tmp2_;
	gint _tmp2__length1;
	guint8* _tmp3_;
	gint _tmp3__length1;
	GDestroyNotify _tmp4_;
	GMemoryInputStream* _tmp5_;
	PrefixInputStream* prefix_input = NULL;
	guint8* _tmp6_;
	gint _tmp6__length1;
	gint _tmp7_ = 0;
	guint8* _tmp8_;
	gint _tmp8__length1;
	GInputStream* _tmp9_;
	PrefixInputStream* _tmp10_;
	guint8* output = NULL;
	guint8* _tmp11_;
	gint output_length1;
	gint _output_size_;
	gsize num_bytes = 0UL;
	GError* _inner_error0_ = NULL;
#line 26 "test-prefix-stream.vala"
	g_return_if_fail (self != NULL);
#line 27 "test-prefix-stream.vala"
	_tmp0_ = string_get_data ("a single man in possession of a good fortune must be in want of a wife" \
".", &_tmp1_);
#line 27 "test-prefix-stream.vala"
	_tmp0__length1 = _tmp1_;
#line 27 "test-prefix-stream.vala"
	_tmp2_ = _tmp0_;
#line 27 "test-prefix-stream.vala"
	_tmp2__length1 = _tmp0__length1;
#line 27 "test-prefix-stream.vala"
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup1 (_tmp2_, _tmp2__length1) : _tmp2_;
#line 27 "test-prefix-stream.vala"
	_tmp3__length1 = _tmp2__length1;
#line 27 "test-prefix-stream.vala"
	_tmp4_ = g_free;
#line 27 "test-prefix-stream.vala"
	_tmp5_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp3_, _tmp3__length1, _tmp4_);
#line 27 "test-prefix-stream.vala"
	input = (GInputStream*) _tmp5_;
#line 30 "test-prefix-stream.vala"
	_tmp6_ = string_get_data ("It is a truth universally acknowledged, that ", &_tmp7_);
#line 30 "test-prefix-stream.vala"
	_tmp6__length1 = _tmp7_;
#line 30 "test-prefix-stream.vala"
	_tmp8_ = _tmp6_;
#line 30 "test-prefix-stream.vala"
	_tmp8__length1 = _tmp6__length1;
#line 30 "test-prefix-stream.vala"
	_tmp9_ = input;
#line 30 "test-prefix-stream.vala"
	input = NULL;
#line 30 "test-prefix-stream.vala"
	_tmp10_ = prefix_input_stream_new (_tmp8_, _tmp8__length1, _tmp9_);
#line 30 "test-prefix-stream.vala"
	prefix_input = _tmp10_;
#line 34 "test-prefix-stream.vala"
	_tmp11_ = g_new0 (guint8, 80);
#line 34 "test-prefix-stream.vala"
	output = _tmp11_;
#line 34 "test-prefix-stream.vala"
	output_length1 = 80;
#line 34 "test-prefix-stream.vala"
	_output_size_ = output_length1;
#line 298 "test-prefix-stream.c"
	{
		gsize _tmp12_ = 0UL;
#line 37 "test-prefix-stream.vala"
		g_input_stream_read_all ((GInputStream*) prefix_input, output, (gsize) output_length1, &_tmp12_, NULL, &_inner_error0_);
#line 37 "test-prefix-stream.vala"
		num_bytes = _tmp12_;
#line 37 "test-prefix-stream.vala"
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 37 "test-prefix-stream.vala"
			if (_inner_error0_->domain == G_IO_ERROR) {
#line 309 "test-prefix-stream.c"
				goto __catch0_g_io_error;
			}
#line 37 "test-prefix-stream.vala"
			output = (g_free (output), NULL);
#line 37 "test-prefix-stream.vala"
			_g_object_unref0 (prefix_input);
#line 37 "test-prefix-stream.vala"
			_g_object_unref0 (input);
#line 37 "test-prefix-stream.vala"
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
#line 37 "test-prefix-stream.vala"
			g_clear_error (&_inner_error0_);
#line 37 "test-prefix-stream.vala"
			return;
#line 324 "test-prefix-stream.c"
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
#line 36 "test-prefix-stream.vala"
		g_clear_error (&_inner_error0_);
#line 332 "test-prefix-stream.c"
	}
	__finally0:
#line 36 "test-prefix-stream.vala"
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 36 "test-prefix-stream.vala"
		output = (g_free (output), NULL);
#line 36 "test-prefix-stream.vala"
		_g_object_unref0 (prefix_input);
#line 36 "test-prefix-stream.vala"
		_g_object_unref0 (input);
#line 36 "test-prefix-stream.vala"
		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);
#line 36 "test-prefix-stream.vala"
		g_clear_error (&_inner_error0_);
#line 36 "test-prefix-stream.vala"
		return;
#line 349 "test-prefix-stream.c"
	}
#line 39 "test-prefix-stream.vala"
	g_assert_true (g_strcmp0 ((const gchar*) output, "It is a truth universally acknowledged, that a single man in possessio" \
"n of a goo") == 0);
#line 26 "test-prefix-stream.vala"
	output = (g_free (output), NULL);
#line 26 "test-prefix-stream.vala"
	_g_object_unref0 (prefix_input);
#line 26 "test-prefix-stream.vala"
	_g_object_unref0 (input);
#line 359 "test-prefix-stream.c"
}

static void
prefix_stream_tests_class_init (PrefixStreamTestsClass * klass,
                                gpointer klass_data)
{
#line 19 "test-prefix-stream.vala"
	prefix_stream_tests_parent_class = g_type_class_peek_parent (klass);
#line 368 "test-prefix-stream.c"
}

static void
prefix_stream_tests_instance_init (PrefixStreamTests * self,
                                   gpointer klass)
{
}

static GType
prefix_stream_tests_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PrefixStreamTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) prefix_stream_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PrefixStreamTests), 0, (GInstanceInitFunc) prefix_stream_tests_instance_init, NULL };
	GType prefix_stream_tests_type_id;
	prefix_stream_tests_type_id = g_type_register_static (TYPE_GEE_TEST_CASE, "PrefixStreamTests", &g_define_type_info, 0);
	return prefix_stream_tests_type_id;
}

GType
prefix_stream_tests_get_type (void)
{
	static volatile gsize prefix_stream_tests_type_id__once = 0;
	if (g_once_init_enter (&prefix_stream_tests_type_id__once)) {
		GType prefix_stream_tests_type_id;
		prefix_stream_tests_type_id = prefix_stream_tests_get_type_once ();
		g_once_init_leave (&prefix_stream_tests_type_id__once, prefix_stream_tests_type_id);
	}
	return prefix_stream_tests_type_id__once;
}

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	GTestSuite* _tmp0_;
	PrefixStreamTests* _tmp1_;
	PrefixStreamTests* _tmp2_;
	GTestSuite* _tmp3_;
	gint result;
#line 44 "test-prefix-stream.vala"
	g_test_init ((gint*) (&args_length1), &args, NULL);
#line 45 "test-prefix-stream.vala"
	g_test_set_nonfatal_assertions ();
#line 46 "test-prefix-stream.vala"
	_tmp0_ = g_test_get_root ();
#line 46 "test-prefix-stream.vala"
	_tmp1_ = prefix_stream_tests_new ();
#line 46 "test-prefix-stream.vala"
	_tmp2_ = _tmp1_;
#line 46 "test-prefix-stream.vala"
	_tmp3_ = gee_test_case_get_suite ((GeeTestCase*) _tmp2_);
#line 46 "test-prefix-stream.vala"
	g_test_suite_add_suite (_tmp0_, _tmp3_);
#line 46 "test-prefix-stream.vala"
	_g_object_unref0 (_tmp2_);
#line 47 "test-prefix-stream.vala"
	result = g_test_run ();
#line 47 "test-prefix-stream.vala"
	return result;
#line 427 "test-prefix-stream.c"
}

int
main (int argc,
      char ** argv)
{
#line 43 "test-prefix-stream.vala"
	return _vala_main (argv, argc);
#line 436 "test-prefix-stream.c"
}

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;
}

