PyObject * advisoryreflist_to_pylist(const HyAdvisoryRefList advisoryreflist, PyObject *sack) { HyAdvisoryRef cadvisoryref; PyObject *advisoryref; PyObject *list = PyList_New(0); if (list == NULL) return NULL; const int count = hy_advisoryreflist_count(advisoryreflist); for (int i = 0; i < count; ++i) { cadvisoryref = hy_advisoryreflist_get_clone(advisoryreflist, i); advisoryref = advisoryrefToPyObject(cadvisoryref, sack); if (advisoryref == NULL) { hy_advisoryref_free(cadvisoryref); goto fail; } int rc = PyList_Append(list, advisoryref); Py_DECREF(advisoryref); if (rc == -1) goto fail; } return list; fail: Py_DECREF(list); return NULL; }
END_TEST START_TEST(test_refs) { HyAdvisoryRef reference; HyAdvisoryRefList reflist = hy_advisory_get_references(advisory); ck_assert_int_eq(hy_advisoryreflist_count(reflist), 2); reference = hy_advisoryreflist_get_clone(reflist, 0); ck_assert_str_eq( hy_advisoryref_get_url(reference), "https://bugzilla.redhat.com/show_bug.cgi?id=472090"); hy_advisoryref_free(reference); reference = hy_advisoryreflist_get_clone(reflist, 1); ck_assert_str_eq( hy_advisoryref_get_url(reference), "https://bugzilla.gnome.com/show_bug.cgi?id=472091"); hy_advisoryref_free(reference); hy_advisoryreflist_free(reflist); }