diff options
author | Milan Crha <mcrha@redhat.com> | 2019-05-15 11:15:41 +0200 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2019-05-15 17:59:46 -0400 |
commit | 250d167bb613af76fb1357ccc9aecf221daa9e2f (patch) | |
tree | 7e60469d73304643598692969c47074028cca3a4 | |
parent | 16e6583d2684e12b22f3df182815606a45e0ebf8 (diff) | |
download | libical-git-250d167bb613af76fb1357ccc9aecf221daa9e2f.tar.gz |
Change the icalarray wrapper and update the array.py test
The libical's icalarray is not suitable for introspection much,
because it operates on bare structures, thus rather not allow
to add/get raw objects to/from it and let it be used for the timezone
arrays only.
The test itself could fail under libasan or a memory issue could
be reported when it had been run under valgrind.
-rw-r--r-- | src/libical-glib/api/i-cal-array.xml | 10 | ||||
-rwxr-xr-x | src/test/libical-glib/array.py | 89 |
2 files changed, 52 insertions, 47 deletions
diff --git a/src/libical-glib/api/i-cal-array.xml b/src/libical-glib/api/i-cal-array.xml index dccb83a6..c10c533f 100644 --- a/src/libical-glib/api/i-cal-array.xml +++ b/src/libical-glib/api/i-cal-array.xml @@ -26,12 +26,12 @@ native = NULL; return ret;</custom> </method> - <method name="i_cal_array_new" corresponds="icalarray_new" kind="constructor" since="1.0"> + <!-- <method name="i_cal_array_new" corresponds="icalarray_new" kind="constructor" since="1.0"> <parameter type="gint" name="element_size" comment="The size of the element of the array"/> <parameter type="gint" name="increment_size" comment="The incremental size when the array is full"/> <returns type="ICalArray *" annotation="transfer full" translator_argus="NULL, FALSE" comment="The newly create #ICalArray with the properties set by @element_size and @increment_size"/> <comment xml:space="preserve">Create a #ICalArray with the element size to be @element_size and increment size to be @increment_size</comment> - </method> + </method> --> <method name="i_cal_array_copy" corresponds="icalarray_copy" kind="clone" since="1.0"> <parameter type="ICalArray *" name="array" annotation="in" comment="The #ICalArray to be cloned."/> <returns type="ICalArray *" annotation="transfer full" translator_argus="NULL, FALSE" comment="The newly cloned #ICalArray with the same value as the @array"/> @@ -41,17 +41,17 @@ <parameter type="ICalArray *" name="array" comment="The #ICalArray to be freed."/> <comment xml:space="preserve">Free the #ICalArray</comment> </method> - <method name="i_cal_array_append" corresponds="icalarray_append" kind="others" since="1.0"> + <!-- <method name="i_cal_array_append" corresponds="icalarray_append" kind="others" since="1.0"> <parameter type="ICalArray *" name="array" comment="The #ICalArray to be appended."/> <parameter type="GObject *" name="element" comment="The element to be appended to the #ICalArray. The reason why to use GOjbect * instead of gpointer is that the variable of type gpointer can only be assigned with none, integer or capsule type. The support for other types would be added in the future."/> <comment xml:space="preserve">Append @element to the end of the array</comment> - </method> + </method> --> <method name="i_cal_array_remove_element_at" corresponds="icalarray_remove_element_at" kind="others" since="1.0"> <parameter type="ICalArray *" name="array" comment="The #ICalArray to be modified."/> <parameter type="gint" name="position" comment="The position in which the element will be removed from the array"/> <comment xml:space="preserve">Remove the element at the @position from the array</comment> </method> - <method name="i_cal_array_element_at" corresponds="icalarray_element_at" kind="others" since="1.0"> + <method name="i_cal_array_element_at" corresponds="icalarray_element_at" annotation="skip" kind="private" since="1.0"> <parameter type="ICalArray *" name="array" comment="The #ICalArray to be queried."/> <parameter type="gint" name="position" comment="The position the target element is located"/> <returns type="GObject *" annotation="transfer none, allow-none" comment="The element located at the @position in the @array"/> diff --git a/src/test/libical-glib/array.py b/src/test/libical-glib/array.py index 074d4cde..9f4a5a34 100755 --- a/src/test/libical-glib/array.py +++ b/src/test/libical-glib/array.py @@ -22,54 +22,59 @@ import gi gi.require_version('ICalGLib', '3.0') -import sys from gi.repository import ICalGLib -from sys import getsizeof -array = ICalGLib.Array.new(256, 100); - -element1 = "hello"; -element2 = "world"; -element3 = "how"; -element4 = "are"; -element5 = "you"; +array = ICalGLib.Timezone.array_new(); #TEST APPEND -attach1 = ICalGLib.Attach.new_from_url(element1); -attach2 = ICalGLib.Attach.new_from_url(element2); -attach3 = ICalGLib.Attach.new_from_url(element3); -attach4 = ICalGLib.Attach.new_from_url(element4); -attach5 = ICalGLib.Attach.new_from_url(element5); +zone0 = ICalGLib.Timezone.get_builtin_timezone("Pacific/Midway"); +zone1 = ICalGLib.Timezone.get_builtin_timezone("America/Vancouver"); +zone2 = ICalGLib.Timezone.get_builtin_timezone("Atlantic/Bermuda"); +zone3 = ICalGLib.Timezone.get_builtin_timezone("Africa/Casablanca"); +zone4 = ICalGLib.Timezone.get_builtin_timezone("Asia/Irkutsk"); + +ICalGLib.Timezone.array_append_from_vtimezone(array, zone0.get_component()); +ICalGLib.Timezone.array_append_from_vtimezone(array, zone1.get_component()); +ICalGLib.Timezone.array_append_from_vtimezone(array, zone2.get_component()); +ICalGLib.Timezone.array_append_from_vtimezone(array, zone3.get_component()); +ICalGLib.Timezone.array_append_from_vtimezone(array, zone4.get_component()); + +assert array.size() == 5 -array.append(attach1); -array.append(attach2); -array.append(attach3); -array.append(attach4); -array.append(attach5); +z0 = ICalGLib.Timezone.array_element_at(array, 0); +assert(z0.get_location() == zone0.get_location()); +z1 = ICalGLib.Timezone.array_element_at(array, 1); +assert(z1.get_location() == zone1.get_location()); +z2 = ICalGLib.Timezone.array_element_at(array, 2); +assert(z2.get_location() == zone2.get_location()); +z3 = ICalGLib.Timezone.array_element_at(array, 3); +assert(z3.get_location() == zone3.get_location()); +z4 = ICalGLib.Timezone.array_element_at(array, 4); +assert(z4.get_location() == zone4.get_location()); -a1 = array.element_at(0); -assert(a1 == attach1); -a2 = array.element_at(1); -assert(a2 == attach2); -a3 = array.element_at(2); -assert(a3 == attach3); -a4 = array.element_at(3); -assert(a4 == attach4); -a5 = array.element_at(4); -assert(a5 == attach5); +array2 = array.copy(); -array = array.copy(); -a1 = array.element_at(0); -assert(a1 == attach1); -a2 = array.element_at(1); -assert(a2 == attach2); -a3 = array.element_at(2); -assert(a3 == attach3); -a4 = array.element_at(3); -assert(a4 == attach4); -a5 = array.element_at(4); -assert(a5 == attach5); +assert array2.size() == 5 + +z0 = ICalGLib.Timezone.array_element_at(array2, 0); +assert(z0.get_location() == zone0.get_location()); +z1 = ICalGLib.Timezone.array_element_at(array2, 1); +assert(z1.get_location() == zone1.get_location()); +z2 = ICalGLib.Timezone.array_element_at(array2, 2); +assert(z2.get_location() == zone2.get_location()); +z3 = ICalGLib.Timezone.array_element_at(array2, 3); +assert(z3.get_location() == zone3.get_location()); +z4 = ICalGLib.Timezone.array_element_at(array2, 4); +assert(z4.get_location() == zone4.get_location()); array.remove_element_at(2); -a3 = array.element_at(2); -assert(a3 == attach4); +assert array.size() == 4 + +z0 = ICalGLib.Timezone.array_element_at(array, 0); +assert(z0.get_location() == zone0.get_location()); +z1 = ICalGLib.Timezone.array_element_at(array, 1); +assert(z1.get_location() == zone1.get_location()); +z3 = ICalGLib.Timezone.array_element_at(array, 2); +assert(z3.get_location() == zone3.get_location()); +z4 = ICalGLib.Timezone.array_element_at(array, 3); +assert(z4.get_location() == zone4.get_location()); |