1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* hgnull.c
* Copyright (C) 2010 Akira TAGOH
*
* Authors:
* Akira TAGOH <akira@tagoh.org>
*
* 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 2 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "hgmem.h"
#include "hgnull.h"
#include "main.h"
hg_mem_t *mem = NULL;
hg_object_vtable_t *vtable = NULL;
/** common **/
void
setup(void)
{
hg_object_init();
mem = hg_mem_new(512);
vtable = hg_object_null_get_vtable();
}
void
teardown(void)
{
gchar *e = hieroglyph_test_pop_error();
if (e) {
g_print("E: %s\n", e);
g_free(e);
}
hg_mem_destroy(mem);
hg_object_fini();
}
/** test cases **/
TDEF (get_capsulated_size)
{
gsize size;
size = vtable->get_capsulated_size();
fail_unless(size == sizeof (hg_object_null_t), "Obtaining the different size: expect: %" G_GSIZE_FORMAT " actual: %" G_GSIZE_FORMAT, sizeof (hg_object_null_t), size);
} TEND
TDEF (initialize)
{
hg_object_null_t *v = NULL, *v2 = NULL;
hg_quark_t q, q2;
hg_quark_t qv;
q = hg_object_null_new(mem, (gpointer *)&v);
fail_unless(q != Qnil, "Unable to create the null object.");
qv = hg_object_null_to_qnull(v);
fail_unless(qv == 0x0000000000000000, "Unexpected result to convert the object to the quark value.");
q2 = hg_qnull_to_object_null(mem, qv, (gpointer *)&v2);
fail_unless(q2 != Qnil, "Unable to create the null object (copying)");
fail_unless(v2 != NULL, "Unable to obtain the pointer of hg_object_null_t");
} TEND
TDEF (free)
{
/* can be done in initialize testcase */
} TEND
TDEF (object_to)
{
/* can be done in initialize testcase */
} TEND
TDEF (object_from)
{
/* can be done in initialize testcase */
} TEND
/****/
Suite *
hieroglyph_suite(void)
{
Suite *s = suite_create("hg_object_null_t");
TCase *tc = tcase_create("Generic Functionalities");
tcase_add_checked_fixture(tc, setup, teardown);
T (get_capsulated_size);
T (initialize);
T (free);
T (object_to);
T (object_from);
suite_add_tcase(s, tc);
return s;
}
|