diff options
author | Akira TAGOH <akira@tagoh.org> | 2007-10-18 12:04:44 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2007-10-18 12:04:44 +0000 |
commit | d5fa7c116f91b39360aa99b110296674bc0ba7ed (patch) | |
tree | dc7e81efcba92cb184d2d0b0790cc208631a4348 | |
parent | bf5354721e0de68731f5aad02afcbb16fbf2e6e8 (diff) |
2007-10-18 Akira TAGOH <akira@tagoh.org>
* tests/Makefile.am: add more test cases.
* hieroglyph/hgobject.c (hg_object_dup): initialize the return value with NULL.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | hieroglyph/hgobject.c | 2 | ||||
-rw-r--r-- | hieroglyph/hgobject.h | 1 | ||||
-rw-r--r-- | hieroglyph/version.h.in | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 30 | ||||
-rw-r--r-- | tests/hgarray.c | 109 | ||||
-rw-r--r-- | tests/hgdict.c | 123 | ||||
-rw-r--r-- | tests/hgfile.c | 109 | ||||
-rw-r--r-- | tests/hgobject.c | 281 | ||||
-rw-r--r-- | tests/hgstring.c | 88 | ||||
-rw-r--r-- | tests/main.h | 1 |
11 files changed, 750 insertions, 8 deletions
@@ -1,3 +1,9 @@ +2007-10-18 Akira TAGOH <akira@tagoh.org> + + * tests/Makefile.am: add more test cases. + + * hieroglyph/hgobject.c (hg_object_dup): initialize the return value with NULL. + 2007-09-18 Akira TAGOH <akira@tagoh.org> * hieroglyph/vm.c (hg_vm_stepi): new function to step one instruction exactly. diff --git a/hieroglyph/hgobject.c b/hieroglyph/hgobject.c index 655707c..e198e2b 100644 --- a/hieroglyph/hgobject.c +++ b/hieroglyph/hgobject.c @@ -166,7 +166,7 @@ hg_object_t * hg_object_dup(hg_vm_t *vm, hg_object_t *object) { - hg_object_t *retval; + hg_object_t *retval = NULL; gsize length; hg_return_val_if_fail (vm != NULL, NULL); diff --git a/hieroglyph/hgobject.h b/hieroglyph/hgobject.h index e82c95a..07bc59c 100644 --- a/hieroglyph/hgobject.h +++ b/hieroglyph/hgobject.h @@ -24,6 +24,7 @@ #ifndef __HIEROGLYPH__HGOBJECT_H__ #define __HIEROGLYPH__HGOBJECT_H__ +#include <math.h> #include <hieroglyph/hgtypes.h> diff --git a/hieroglyph/version.h.in b/hieroglyph/version.h.in index 76dbd93..fa38507 100644 --- a/hieroglyph/version.h.in +++ b/hieroglyph/version.h.in @@ -21,8 +21,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ -#ifndef c51accf3-3007-457c-b903-2c1d7d5bb30cVERSION_H__ -#define c51accf3-3007-457c-b903-2c1d7d5bb30cVERSION_H__ +#ifndef f421545e-1fe0-4719-8407-50677cae0f6eVERSION_H__ +#define f421545e-1fe0-4719-8407-50677cae0f6eVERSION_H__ #include <glib/gmacros.h> @@ -30,10 +30,10 @@ G_BEGIN_DECLS #define HIEROGLYPH_VERSION "@VERSION@" -#define HIEROGLYPH_UUID "c51accf3-3007-457c-b903-2c1d7d5bb30c" +#define HIEROGLYPH_UUID "f421545e-1fe0-4719-8407-50677cae0f6e" const char *__hg_rcsid G_GNUC_UNUSED = "$Rev$"; G_END_DECLS -#endif /* c51accf3-3007-457c-b903-2c1d7d5bb30cVERSION_H__ */ +#endif /* f421545e-1fe0-4719-8407-50677cae0f6eVERSION_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index bc24fd0..ffb54fc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ NULL = -SUBDIRS = ps +SUBDIRS = INCLUDES = \ -I$(top_srcdir)/hieroglyph \ @@ -16,7 +16,11 @@ LDADDS = \ noinst_PROGRAMS = \ test-hgobject \ + test-hgarray \ + test-hgdict \ + test-hgfile \ test-hgstack \ + test-hgstring \ $(NULL) test_hgobject_SOURCES = \ @@ -24,12 +28,36 @@ test_hgobject_SOURCES = \ hgobject.c \ $(NULL) test_hgobject_LDADD = $(LDADDS) +test_hgarray_SOURCES = \ + main.c \ + hgarray.c \ + $(NULL) +test_hgarray_LDADD = $(LDADDS) +test_hgdict_SOURCES = \ + main.c \ + hgdict.c \ + $(NULL) +test_hgdict_LDADD = $(LDADDS) +test_hgfile_SOURCES = \ + main.c \ + hgfile.c \ + $(NULL) +test_hgfile_LDADD = $(LDADDS) test_hgstack_SOURCES = \ hgstack.c \ $(NULL) test_hgstack_LDADD = $(LDADDS) +test_hgstring_SOURCES = \ + main.c \ + hgstring.c \ + $(NULL) +test_hgstring_LDADD = $(LDADDS) TESTS = \ test-hgobject \ + test-hgarray \ + test-hgdict \ + test-hgfile \ test-hgstack \ + test-hgstring \ $(NULL) diff --git a/tests/hgarray.c b/tests/hgarray.c new file mode 100644 index 0000000..a79f3a1 --- /dev/null +++ b/tests/hgarray.c @@ -0,0 +1,109 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hgarray.c + * Copyright (C) 2007 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 <hieroglyph/hgarray.h> +#include <hieroglyph/vm.h> +#include "main.h" + + +hg_vm_t *vm; +hg_object_t *obj; + +void +setup(void) +{ + vm = hg_vm_new(); +} + +void +teardown(void) +{ + hg_vm_destroy(vm); +} + +/* array object */ +TDEF (hg_object_array_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_subarray_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_put) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_get) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_get_const) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_compare) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_array_dump) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +/************************************************************/ +Suite * +hieroglyph_suite(void) +{ + Suite *s = suite_create("hg_array_t"); + TCase *tc = tcase_create("Generic Functionalities"); + + tcase_add_checked_fixture(tc, setup, teardown); + T (hg_object_array_new); + T (hg_object_array_subarray_new); + T (hg_object_array_put); + T (hg_object_array_get); + T (hg_object_array_get_const); + T (hg_object_array_compare); + T (hg_object_array_dump); + + suite_add_tcase(s, tc); + + return s; +} diff --git a/tests/hgdict.c b/tests/hgdict.c new file mode 100644 index 0000000..a4140c1 --- /dev/null +++ b/tests/hgdict.c @@ -0,0 +1,123 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hgdict.c + * Copyright (C) 2007 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 <hieroglyph/hgdict.h> +#include <hieroglyph/vm.h> +#include "main.h" + + +hg_vm_t *vm; +hg_object_t *obj; + +void +setup(void) +{ + vm = hg_vm_new(); +} + +void +teardown(void) +{ + hg_vm_destroy(vm); +} + +/* dict object */ +TDEF (hg_object_dict_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_compare) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_dump) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_insert) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_insert_without_consistency) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_replace) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_replace_without_consistency) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_remove) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_dict_lookup) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +/************************************************************/ +Suite * +hieroglyph_suite(void) +{ + Suite *s = suite_create("hg_dict_t"); + TCase *tc = tcase_create("Generic Functionalities"); + + tcase_add_checked_fixture(tc, setup, teardown); + T (hg_object_dict_new); + T (hg_object_dict_compare); + T (hg_object_dict_dump); + T (hg_object_dict_insert); + T (hg_object_dict_insert_without_consistency); + T (hg_object_dict_replace); + T (hg_object_dict_replace_without_consistency); + T (hg_object_dict_remove); + T (hg_object_dict_lookup); + + suite_add_tcase(s, tc); + + return s; +} diff --git a/tests/hgfile.c b/tests/hgfile.c new file mode 100644 index 0000000..5a2be10 --- /dev/null +++ b/tests/hgfile.c @@ -0,0 +1,109 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hgfile.c + * Copyright (C) 2007 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 <hieroglyph/hgfile.h> +#include <hieroglyph/vm.h> +#include "main.h" + + +hg_vm_t *vm; +hg_object_t *obj; + +void +setup(void) +{ + vm = hg_vm_new(); +} + +void +teardown(void) +{ + hg_vm_destroy(vm); +} + +/* file object */ +TDEF (hg_object_file_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_new_from_string) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_new_with_custom) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_free) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_notify_error) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_compare) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_file_dump) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +/************************************************************/ +Suite * +hieroglyph_suite(void) +{ + Suite *s = suite_create("hg_file_t"); + TCase *tc = tcase_create("Generic Functionalities"); + + tcase_add_checked_fixture(tc, setup, teardown); + T (hg_object_file_new); + T (hg_object_file_new_from_string); + T (hg_object_file_new_with_custom); + T (hg_object_file_free); + T (hg_object_file_notify_error); + T (hg_object_file_compare); + T (hg_object_file_dump); + + suite_add_tcase(s, tc); + + return s; +} diff --git a/tests/hgobject.c b/tests/hgobject.c index 1aa9f08..8be5fb0 100644 --- a/tests/hgobject.c +++ b/tests/hgobject.c @@ -21,6 +21,9 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include <hieroglyph/hgobject.h> #include <hieroglyph/vm.h> #include "main.h" @@ -48,14 +51,14 @@ TDEF (hg_object_new) obj = hg_object_new(vm, 1); - fail_unless(obj != NULL, "Failed to create an object"); + TNUL (obj); fail_unless(HG_OBJECT_GET_N_OBJECTS (obj) == 1, "The amount of the object is different."); hg_object_free(vm, obj); obj = hg_object_new(vm, 10); - fail_unless(obj != NULL, "Failed to create an object"); + TNUL (obj); fail_unless(HG_OBJECT_GET_N_OBJECTS (obj) == 10, "The amount of the object is different."); hg_object_free(vm, obj); @@ -74,26 +77,295 @@ TEND TDEF (hg_object_sized_new) { + obj = hg_object_sized_new(vm, 10); + + TNUL (obj); + fail_unless(HG_OBJECT_GET_N_OBJECTS (obj) == 1, "The amount of the object is different."); + fail_unless(HG_OBJECT_HEADER (obj)->total_length == hg_n_alignof (sizeof (hg_object_header_t) + sizeof (_hg_object_t) + 10), "The length of the object is different."); + + hg_object_free(vm, obj); + + obj = hg_object_sized_new(vm, 0); + + TNUL (obj); + fail_unless(HG_OBJECT_GET_N_OBJECTS (obj) == 1, "The amount of the object is different."); + fail_unless(HG_OBJECT_HEADER (obj)->total_length == hg_n_alignof (sizeof (hg_object_header_t) + sizeof (_hg_object_t)), "The length of the object is different."); + + hg_object_free(vm, obj); } TEND TDEF (hg_object_dup) { + hg_object_t *obj2; + + obj = hg_object_new(vm, 1); + + TNUL (obj); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 == NULL, "Not allowed to duplicate the uninitialized object"); + + hg_object_free(vm, obj); + + /* null */ + obj = hg_object_null_new(vm); + + fail_unless(obj != NULL, "Failed to create a null object"); + fail_unless(HG_OBJECT_IS_NULL (obj), "Created object isn't a null object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a null object"); + fail_unless(HG_OBJECT_IS_NULL (obj2), "Duplicated object isn't a null object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* integer */ + obj = hg_object_integer_new(vm, 123); + + fail_unless(obj != NULL, "Failed to create an integer object"); + fail_unless(HG_OBJECT_IS_INTEGER (obj), "Created object isn't an integer object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate an integer object"); + fail_unless(HG_OBJECT_IS_INTEGER (obj2), "Duplicated object isn't an integer object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* real */ + obj = hg_object_real_new(vm, 0.01); + + fail_unless(obj != NULL, "Failed to create an real object"); + fail_unless(HG_OBJECT_IS_REAL (obj), "Created object isn't an real object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate an real object"); + fail_unless(HG_OBJECT_IS_REAL (obj2), "Duplicated object isn't an real object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* name */ + obj = hg_object_name_new(vm, "foo", FALSE); + + fail_unless(obj != NULL, "Failed to create a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj), "Created object isn't a name object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj2), "Duplicated object isn't a name object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* name eval */ + obj = hg_object_name_new(vm, "foo", TRUE); + + fail_unless(obj != NULL, "Failed to create a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj), "Created object isn't a name(eval) object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a name object"); + fail_unless(HG_OBJECT_IS_EVAL (obj2), "Duplicated object isn't a name(eval) object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* system encoding */ + obj = hg_object_system_encoding_new(vm, HG_enc_abs, FALSE); + + fail_unless(obj != NULL, "Failed to create a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj), "Created object isn't a name object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj2), "Duplicated object isn't a name object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* system encoding eval */ + obj = hg_object_system_encoding_new(vm, HG_enc_abs, TRUE); + + fail_unless(obj != NULL, "Failed to create a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj), "Created object isn't a name(eval) object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj2), "Duplicated object isn't a name(eval) object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* boolean */ + obj = hg_object_boolean_new(vm, TRUE); + + fail_unless(obj != NULL, "Failed to create a boolean object"); + fail_unless(HG_OBJECT_IS_BOOLEAN (obj), "Created object isn't a boolean object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a boolean object"); + fail_unless(HG_OBJECT_IS_BOOLEAN (obj2), "Duplicated object isn't a boolean object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* mark */ + obj = hg_object_mark_new(vm); + + fail_unless(obj != NULL, "Failed to create a mark object"); + fail_unless(HG_OBJECT_IS_MARK (obj), "Created object isn't a mark object"); + obj2 = hg_object_dup(vm, obj); + fail_unless(obj2 != NULL, "Failed to duplicate a mark object"); + fail_unless(HG_OBJECT_IS_MARK (obj2), "Duplicated object isn't a mark object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly duplicated"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); } TEND TDEF (hg_object_copy) { + hg_object_t *obj2; + + obj = hg_object_new(vm, 1); + + TNUL (obj); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy an uninitialized object"); + + hg_object_free(vm, obj); + + /* null */ + obj = hg_object_null_new(vm); + + fail_unless(obj != NULL, "Failed to create a null object"); + fail_unless(HG_OBJECT_IS_NULL (obj), "Created object isn't a null object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a null object"); + fail_unless(HG_OBJECT_IS_NULL (obj2), "Copied object isn't a null object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* integer */ + obj = hg_object_integer_new(vm, 123); + + fail_unless(obj != NULL, "Failed to create an integer object"); + fail_unless(HG_OBJECT_IS_INTEGER (obj), "Created object isn't an integer object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy an integer object"); + fail_unless(HG_OBJECT_IS_INTEGER (obj2), "Copied object isn't an integer object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* real */ + obj = hg_object_real_new(vm, 0.01); + + fail_unless(obj != NULL, "Failed to create an real object"); + fail_unless(HG_OBJECT_IS_REAL (obj), "Created object isn't an real object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy an real object"); + fail_unless(HG_OBJECT_IS_REAL (obj2), "Copied object isn't an real object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* name */ + obj = hg_object_name_new(vm, "foo", FALSE); + + fail_unless(obj != NULL, "Failed to create a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj), "Created object isn't a name object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj2), "Copied object isn't a name object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* name eval */ + obj = hg_object_name_new(vm, "foo", TRUE); + + fail_unless(obj != NULL, "Failed to create a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj), "Created object isn't a name(eval) object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a name object"); + fail_unless(HG_OBJECT_IS_EVAL (obj2), "Copied object isn't a name(eval) object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* system encoding */ + obj = hg_object_system_encoding_new(vm, HG_enc_abs, FALSE); + + fail_unless(obj != NULL, "Failed to create a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj), "Created object isn't a name object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a name object"); + fail_unless(HG_OBJECT_IS_NAME (obj2), "Copied object isn't a name object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* system encoding eval */ + obj = hg_object_system_encoding_new(vm, HG_enc_abs, TRUE); + + fail_unless(obj != NULL, "Failed to create a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj), "Created object isn't a name(eval) object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a name(eval) object"); + fail_unless(HG_OBJECT_IS_EVAL (obj2), "Copied object isn't a name(eval) object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* boolean */ + obj = hg_object_boolean_new(vm, TRUE); + + fail_unless(obj != NULL, "Failed to create a boolean object"); + fail_unless(HG_OBJECT_IS_BOOLEAN (obj), "Created object isn't a boolean object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a boolean object"); + fail_unless(HG_OBJECT_IS_BOOLEAN (obj2), "Copied object isn't a boolean object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); + + /* mark */ + obj = hg_object_mark_new(vm); + + fail_unless(obj != NULL, "Failed to create a mark object"); + fail_unless(HG_OBJECT_IS_MARK (obj), "Created object isn't a mark object"); + obj2 = hg_object_copy(vm, obj); + fail_unless(obj2 != NULL, "Failed to copy a mark object"); + fail_unless(HG_OBJECT_IS_MARK (obj2), "Copied object isn't a mark object"); + fail_unless(hg_object_compare(obj, obj2), "Object wasn't exactly copied"); + + hg_object_free(vm, obj); + hg_object_free(vm, obj2); } TEND TDEF (hg_object_compare) { + /* almost test cases has been done at hg_object_dup/copy */ } TEND TDEF (hg_object_dump) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND @@ -132,30 +404,35 @@ TEND /* real object */ TDEF (hg_object_real_new) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND /* name object */ TDEF (hg_object_name_new) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND /* system encoding object */ TDEF (hg_object_system_encoding_new) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND /* boolean object */ TDEF (hg_object_boolean_new) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND /* mark object */ TDEF (hg_object_mark_new) { + g_print("FIXME: %s\n", __FUNCTION__); } TEND diff --git a/tests/hgstring.c b/tests/hgstring.c new file mode 100644 index 0000000..fc33977 --- /dev/null +++ b/tests/hgstring.c @@ -0,0 +1,88 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hgstring.c + * Copyright (C) 2007 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 <hieroglyph/hgstring.h> +#include <hieroglyph/vm.h> +#include "main.h" + + +hg_vm_t *vm; +hg_object_t *obj; + +void +setup(void) +{ + vm = hg_vm_new(); +} + +void +teardown(void) +{ + hg_vm_destroy(vm); +} + +/* string object */ +TDEF (hg_object_string_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_string_sized_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_string_substring_new) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +TDEF (hg_object_string_compare) +{ + g_print("FIXME: %s\n", __FUNCTION__); +} +TEND + +/************************************************************/ +Suite * +hieroglyph_suite(void) +{ + Suite *s = suite_create("hg_string_t"); + TCase *tc = tcase_create("Generic Functionalities"); + + tcase_add_checked_fixture(tc, setup, teardown); + T (hg_object_string_new); + T (hg_object_string_sized_new); + T (hg_object_string_substring_new); + T (hg_object_string_compare); + + suite_add_tcase(s, tc); + + return s; +} diff --git a/tests/main.h b/tests/main.h index 681c75b..e65bae2 100644 --- a/tests/main.h +++ b/tests/main.h @@ -29,5 +29,6 @@ #define TDEF(fn) START_TEST (test_ ## fn) #define TEND END_TEST #define T(fn) tcase_add_test(tc, test_ ## fn) +#define TNUL(obj) fail_unless((obj) != NULL, "Failed to create an object") #endif /* __HIEROGLYPH_TEST_MAIN_H__ */ |