signed char comps_docgroup_cmp_u(COMPS_Object *group1, COMPS_Object *group2) { #define _group1 ((COMPS_DocGroup*)group1) #define _group2 ((COMPS_DocGroup*)group2) if (!comps_object_cmp((COMPS_Object*)_group1->properties, (COMPS_Object*)_group2->properties)) { printf("Group properties cmp fail\n"); return 0; } //printf("group cmp properties pass\n"); if (!comps_object_cmp((COMPS_Object*)_group1->name_by_lang, (COMPS_Object*)_group2->name_by_lang)) { //printf("Group name_by_lang cmp fail\n"); return 0; } //printf("group cmp name_by_lang pass\n"); if (!comps_object_cmp((COMPS_Object*)_group1->desc_by_lang, (COMPS_Object*)_group2->desc_by_lang)) { //printf("Group desc_by_lang cmp fail\n"); return 0; } //printf("group cmp desc_by_lang pass\n"); if (!comps_object_cmp((COMPS_Object*)_group1->packages, (COMPS_Object*)_group2->packages)) { //printf("Group packages cmp fail\n"); return 0; } //printf("group cmp packages pass\n"); return 1; #undef _group1 #undef _group2 }
signed char comps_doccategory_cmp_u(COMPS_Object *cat1, COMPS_Object *cat2) { #define _cat1 ((COMPS_DocCategory*)cat1) #define _cat2 ((COMPS_DocCategory*)cat2) if (!comps_object_cmp((COMPS_Object*)_cat1->properties, (COMPS_Object*)_cat2->properties)) { //printf("Category properties cmp fail\n"); return 0; } if (!comps_object_cmp((COMPS_Object*)_cat1->name_by_lang, (COMPS_Object*)_cat2->name_by_lang)) { //printf("Category name_by_lang cmp fail\n"); return 0; } if (!comps_object_cmp((COMPS_Object*)_cat1->desc_by_lang, (COMPS_Object*)_cat2->desc_by_lang)) { //printf("Category desc_by_lang cmp fail\n"); return 0; } if (!comps_object_cmp((COMPS_Object*)_cat1->group_ids, (COMPS_Object*)_cat2->group_ids)) { //printf("Category group_ids cmp fail\n"); return 0; } //printf("group category pass\n"); return 1; #undef _cat1 #undef _cat2 }
signed char comps_docpackage_cmp_u(COMPS_Object *pkg1, COMPS_Object *pkg2) { #define _pkg1 ((COMPS_DocGroupPackage*)pkg1) #define _pkg2 ((COMPS_DocGroupPackage*)pkg2) if (!comps_object_cmp((COMPS_Object*)_pkg1->name, (COMPS_Object*)_pkg2->name)) return 0; if (!comps_object_cmp((COMPS_Object*)_pkg1->requires, (COMPS_Object*)_pkg2->requires)) return 0; if (_pkg1->type != _pkg2->type) return 0; return 1; #undef _pkg1 #undef _pkg2 }
END_TEST int check_errors(COMPS_Log *log, COMPS_LogEntry ** known_errors, int known_len) { COMPS_HSListItem *it; int i; it = log->entries->first; for (i = 0; it != NULL && i != known_len; it = it->next, i++) { fail_if(((COMPS_LogEntry*)it->data)->arg_count != known_errors[i]->arg_count, "%d err opt_message doesn't match (%d != %d)", i, ((COMPS_LogEntry*)it->data)->arg_count, known_errors[i]->arg_count); fail_if(((COMPS_LogEntry*)it->data)->code != known_errors[i]->code, "%d. err code different\n (%d != %d)", i, ((COMPS_LogEntry*)it->data)->code, known_errors[i]->code); for (int x = 0; x < known_errors[i]->arg_count; x++) { char *_x, *_y; _x = comps_object_tostr(((COMPS_LogEntry*)it->data)->args[x]); _y = comps_object_tostr(known_errors[i]->args[x]); fail_if(comps_object_cmp(((COMPS_LogEntry*)it->data)->args[x], known_errors[i]->args[x]) == 0, "%d. %s != %s", x, _x, _y); free(_x); free(_y); } } return i; }
char comps_objmrtree_paircmp(void *obj1, void *obj2) { if (strcmp(((COMPS_ObjMRTreePair*)obj1)->key, ((COMPS_ObjMRTreePair*)obj2)->key) != 0) return 0; return comps_object_cmp((COMPS_Object*)((COMPS_ObjMRTreePair*)obj1)->data, (COMPS_Object*)((COMPS_ObjMRTreePair*)obj1)->data); }
char comps_objrtree_paircmp(void *obj1, void *obj2) { //printf("comparing %s with %s\n", ((COMPS_ObjRTreePair*)obj1)->key, // ((COMPS_ObjRTreePair*)obj2)->key); if (strcmp(((COMPS_ObjRTreePair*)obj1)->key, ((COMPS_ObjRTreePair*)obj2)->key) != 0) return 0; return comps_object_cmp(((COMPS_ObjRTreePair*)obj1)->data, ((COMPS_ObjRTreePair*)obj2)->data); }
char __comps_doccategory_idcmp(void *c1, void *c2) { COMPS_Object *obj1, *obj2; char ret; obj1 = comps_objdict_get(((COMPS_DocCategory*)c1)->properties, "id"); obj2 = comps_objdict_get(((COMPS_DocCategory*)c2)->properties, "id"); ret = comps_object_cmp(obj1, obj2); COMPS_OBJECT_DESTROY(obj1); COMPS_OBJECT_DESTROY(obj2); return ret; }
char __comps_docgroup_idcmp(void *g1, void *g2) { COMPS_Object *obj1, *obj2; char ret; obj1 = comps_objdict_get(((COMPS_DocGroup*)g1)->properties, "id"); obj2 = comps_objdict_get(((COMPS_DocGroup*)g2)->properties, "id"); ret = comps_object_cmp(obj1, obj2); COMPS_OBJECT_DESTROY(obj1); COMPS_OBJECT_DESTROY(obj2); return ret; }
PyObject* PyCOMPSDict_cmp(PyObject *self, PyObject *other, int op) { char ret; if (other == NULL) { PyErr_Format(PyExc_TypeError, "Get NULL as Dict subclass"); return NULL; } if ((Py_TYPE(other) != Py_TYPE(self) && !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { PyErr_Format(PyExc_TypeError, "Not Dict subclass, %s", Py_TYPE(other)->tp_name); return NULL; } if (op != Py_EQ && op != Py_NE) { PyErr_Format(PyExc_TypeError, "Unsuported operator"); return Py_INCREF(Py_NotImplemented), Py_NotImplemented; } ret = comps_object_cmp((COMPS_Object*)((PyCOMPS_Dict*)self)->dict, (COMPS_Object*)((PyCOMPS_Dict*)other)->dict); if ((!ret && op == Py_NE) || (ret && op == Py_EQ)) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } }
char __comps_docpackage_idcmp(void *pkg1, void *pkg2) { return comps_object_cmp((COMPS_Object*)((COMPS_DocGroupPackage*)pkg1)->name, (COMPS_Object*)((COMPS_DocGroupPackage*)pkg2)->name); }