Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Add tests for unions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomeu Vizoso committed Apr 23, 2010
1 parent 781db9e commit 95b9f18
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
97 changes: 97 additions & 0 deletions gir/gimarshallingtests.c
Expand Up @@ -2503,6 +2503,103 @@ g_i_marshalling_tests__boxed_struct_inout (GIMarshallingTestsBoxedStruct **struc
(*struct_)->long_ = 0;
}

static GIMarshallingTestsUnion *
g_i_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
{
GIMarshallingTestsUnion *new_union;

new_union = g_slice_new (GIMarshallingTestsUnion);

*new_union = *union_;

return new_union;
}

static void
g_i_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
{
g_slice_free (GIMarshallingTestsUnion, union_);
}

GType
g_i_marshalling_tests_union_get_type (void)
{
static GType type = 0;

if (type == 0) {
type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
(GBoxedCopyFunc) g_i_marshalling_tests_union_copy,
(GBoxedFreeFunc) g_i_marshalling_tests_union_free);
}

return type;
}

/**
* g_i_marshalling_tests__union_return:
* Returns: (transfer none):
*/
GIMarshallingTestsUnion *
g_i_marshalling_tests__union_return (void)
{
static GIMarshallingTestsUnion *union_ = NULL;

if (union_ == NULL) {
union_ = g_new(GIMarshallingTestsUnion, 1);

union_->long_ = 42;
}

return union_;
}

/**
* g_i_marshalling_tests__union_in:
* @union_: (transfer none):
*/
void
g_i_marshalling_tests__union_in (GIMarshallingTestsUnion *union_)
{
g_assert(union_->long_ == 42);
}

/**
* g_i_marshalling_tests__union_out:
* @union_: (out) (transfer none):
*/
void
g_i_marshalling_tests__union_out (GIMarshallingTestsUnion **union_)
{
static GIMarshallingTestsUnion *new_union = NULL;

if (new_union == NULL) {
new_union = g_new(GIMarshallingTestsUnion, 1);

new_union->long_ = 42;
}

*union_ = new_union;
}

/**
* g_i_marshalling_tests__union_inout:
* @union_: (inout) (transfer none):
*/
void
g_i_marshalling_tests__union_inout (GIMarshallingTestsUnion **union_)
{
g_assert((*union_)->long_ == 42);

(*union_)->long_ = 0;
}

void
g_i_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
{
g_assert(union_->long_ == 42);
}



enum
{
Expand Down
15 changes: 15 additions & 0 deletions gir/gimarshallingtests.h
Expand Up @@ -497,6 +497,21 @@ void g_i_marshalling_tests__boxed_struct_out (GIMarshallingTestsBoxedStruct **st

void g_i_marshalling_tests__boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_);

typedef union {
glong long_;
} GIMarshallingTestsUnion;

GType g_i_marshalling_tests_union_get_type (void) G_GNUC_CONST;

GIMarshallingTestsUnion *g_i_marshalling_tests__union_return (void);

void g_i_marshalling_tests__union_in (GIMarshallingTestsUnion *union_);

void g_i_marshalling_tests__union_out (GIMarshallingTestsUnion **union_);

void g_i_marshalling_tests__union_inout (GIMarshallingTestsUnion **union_);

void g_i_marshalling_tests_union_method (GIMarshallingTestsUnion *union_);

/* Object */

Expand Down

0 comments on commit 95b9f18

Please sign in to comment.