2
#include <glib-object.h>
4
#include "../src/thrift_struct.c"
6
/* tests to ensure we can extend a ThriftStruct */
8
struct _ThriftTestStruct
12
typedef struct _ThriftTestStruct ThriftTestStruct;
14
struct _ThriftTestStructClass
16
ThriftStructClass parent;
18
typedef struct _ThriftTestStructClass ThriftTestStructClass;
20
GType thrift_test_struct_get_type (void);
22
#define THRIFT_TYPE_TEST_STRUCT (thrift_test_struct_get_type ())
23
#define THRIFT_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
24
THRIFT_TYPE_TEST_STRUCT, \
26
#define THRIFT_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
27
THRIFT_TYPE_TEST_STRUCT, \
28
ThriftTestStructClass))
29
#define THRIFT_IS_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
30
THRIFT_TYPE_TEST_STRUCT))
31
#define THRIFT_IS_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
32
THRIFT_TYPE_TEST_STRUCT))
33
#define THRIFT_TEST_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
34
THRIFT_TYPE_TEST_STRUCT, \
35
ThriftTestStructClass))
37
/* test declarations */
38
gint32 thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
40
gint32 thrift_test_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
44
thrift_test_struct_class_init (ThriftTestStructClass *cls)
46
ThriftStructClass *ts_cls = THRIFT_STRUCT_CLASS (cls);
47
ts_cls->read = thrift_test_struct_read;
48
ts_cls->write = thrift_test_struct_write;
52
thrift_test_struct_instance_init (ThriftTestStruct *s)
58
thrift_test_struct_get_type (void)
60
static GType type = 0;
64
static const GTypeInfo type_info =
66
sizeof (ThriftTestStructClass),
69
(GClassInitFunc) thrift_test_struct_class_init,
72
sizeof (ThriftTestStruct),
74
(GInstanceInitFunc) thrift_test_struct_instance_init,
78
type = g_type_register_static (THRIFT_TYPE_STRUCT,
79
"ThriftTestStructType", &type_info, 0);
86
thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
93
thrift_test_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
101
test_initialize_object (void)
103
ThriftTestStruct *t = NULL;
105
t = g_object_new (THRIFT_TYPE_TEST_STRUCT, NULL);
106
assert ( THRIFT_IS_STRUCT (t));
107
thrift_struct_read (THRIFT_STRUCT (t), NULL, NULL);
108
thrift_struct_write (THRIFT_STRUCT (t), NULL, NULL);
109
thrift_test_struct_read (THRIFT_STRUCT (t), NULL, NULL);
110
thrift_test_struct_write (THRIFT_STRUCT (t), NULL, NULL);
118
test_initialize_object ();