END_TEST START_TEST(test_comps_parse5) { FILE *fp; //char *err_log; COMPS_Parsed *parsed; //COMPS_ListItem *it; //int ret int i; fprintf(stderr, "## Running test_parse5\n\n"); COMPS_LogEntry* known_errors[2]; known_errors[0] = __log_entry_x(COMPS_ERR_TEXT_BETWEEN, 3, comps_str("some stray"), comps_num(6), comps_num(4)); known_errors[1] = __log_entry_x(COMPS_ERR_TEXT_BETWEEN, 3, comps_str(" some stray"), comps_num(189), comps_num(2)); parsed = comps_parse_parsed_create(); comps_parse_parsed_init(parsed, "UTF-8", 1); fp = fopen("sample_comps_bad3.xml", "r"); comps_parse_file(parsed, fp, NULL); //comps_log_print(parsed->log); fail_if(parsed->log->entries->first == NULL); check_errors(parsed->log, known_errors, 2); //comps2xml_f(parsed->comps_doc, "fed2.xml", 0); for (i = 0; i < 2; i++) { comps_log_entry_destroy(known_errors[i]); } comps_parse_parsed_destroy(parsed); }
void __comps_check_allready_set(COMPS_Object *param, char *param_name, COMPS_Parsed *parsed) { if (param) { comps_log_error_x(parsed->log, COMPS_ERR_ELEM_ALREADYSET, 3, comps_str(param_name), comps_num(parser_line), comps_num(parser_col)); } COMPS_OBJECT_DESTROY(param); }
void __comps_check_required_param(COMPS_Object *param, char *param_name, COMPS_Parsed *parsed) { if (!param) { comps_log_error_x(parsed->log, COMPS_ERR_ELEM_REQUIRED, 3, comps_str(param_name), comps_num(parser_line), comps_num(parser_col)); } COMPS_OBJECT_DESTROY(param); }
void comps_docpackage_set_basearchonly(COMPS_DocGroupPackage *pkg, int basearchonly, bool unset) { (void)unset; if (pkg->basearchonly) { COMPS_OBJECT_DESTROY(pkg->basearchonly); } pkg->basearchonly = comps_num(basearchonly); }
END_TEST START_TEST(test_comps_parse3) { FILE *fp; //char *err_log, char *tmp_ch; COMPS_Parsed *parsed; COMPS_ObjListIt *it; int i; COMPS_ObjList *tmplist; COMPS_LogEntry* known_errors[3]; char *str; COMPS_Object *tmpobj; fprintf(stderr, "## Running test_parse3\n\n"); known_errors[0] = __log_entry_x(COMPS_ERR_ELEM_REQUIRED, 3, comps_str("id"), comps_num(188), comps_num(2)); known_errors[1] = __log_entry_x(COMPS_ERR_ELEM_REQUIRED, 3, comps_str("name"), comps_num(188), comps_num(2)); known_errors[2] = __log_entry_x(COMPS_ERR_ELEM_REQUIRED, 3, comps_str("description"), comps_num(188), comps_num(2)); parsed = comps_parse_parsed_create(); comps_parse_parsed_init(parsed, "UTF-8", 1); fp = fopen("sample_comps_bad1.xml", "r"); comps_parse_file(parsed, fp, NULL); fail_if(parsed->log->entries->first == NULL); check_errors(parsed->log, known_errors, 3); for (i = 0; i < 3; i++) { comps_log_entry_destroy(known_errors[i]); } tmplist = comps_doc_groups(parsed->comps_doc); it = tmplist->first; /*pairlist = comps_rtree_pairs(((COMPS_DocCategory*)it->data)->properties); for (hsit = pairlist->first; hsit != NULL; hsit = hsit->next){ printf("%s = %s\n", ((COMPS_RTreePair*)hsit->data)->key, ((COMPS_RTreePair*)hsit->data)->data); }*/ COMPS_OBJECT_DESTROY(tmplist); tmpobj = comps_docgroup_get_id((COMPS_DocGroup*)it->comps_obj); fail_if(tmpobj, "%d. category should have NULL id\n"); COMPS_OBJECT_DESTROY(tmpobj); tmpobj = comps_docgroup_get_name((COMPS_DocGroup*)it->comps_obj); fail_if(tmpobj, "%d. category should have NULL name\n"); COMPS_OBJECT_DESTROY(tmpobj); tmpobj = comps_docgroup_get_desc((COMPS_DocGroup*)it->comps_obj); fail_if(tmpobj, "%d. category should have NULL description\n"); COMPS_OBJECT_DESTROY(tmpobj); comps_parse_parsed_destroy(parsed); }
int pycomps_group_boolattr_setter(PyObject *self, PyObject *val, void *closure) { long tmp; COMPS_Object *tmp_prop; if (!val) { PyErr_Format(PyExc_TypeError, "Can't delete %s", (char*)closure); return -1; } if (val && !PyBool_Check(val)) { PyErr_SetString(PyExc_TypeError, "Not bool object"); return -1; } tmp = (val == Py_True)?1:0; tmp_prop = (COMPS_Object*) comps_num(tmp); comps_objdict_set_x(((PyCOMPS_Group*)self)->group->properties, (char*)closure, tmp_prop); return 0; }
END_TEST START_TEST(test_comps_parse4) { FILE *fp; //char *err_log; COMPS_Parsed *parsed; //COMPS_ListItem *it; //int ret, int i; //COMPS_List * tmplist; COMPS_LogEntry* known_errors[15]; fprintf(stderr, "## Running test_parse4\n\n"); known_errors[0] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("id"), comps_num(4), comps_num(2)); known_errors[1] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("packagereq"), comps_num(158), comps_num(4)); known_errors[2] = __log_entry_x(COMPS_ERR_ELEM_ALREADYSET, 3, comps_str("langonly"), comps_num(274), comps_num(16)); known_errors[3] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(588), comps_num(4)); known_errors[4] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("grouplist"), comps_num(880), comps_num(2)); known_errors[5] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(881), comps_num(4)); known_errors[6] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(882), comps_num(4)); known_errors[7] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(883), comps_num(4)); known_errors[8] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(884), comps_num(4)); known_errors[9] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(885), comps_num(4)); known_errors[10] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(886), comps_num(4)); known_errors[11] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(887), comps_num(4)); known_errors[12] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("id"), comps_num(1210), comps_num(2)); known_errors[13] = __log_entry_x(COMPS_ERR_NOPARENT, 3, comps_str("groupid"), comps_num(1228), comps_num(4)); known_errors[14] = __log_entry_x(COMPS_ERR_ELEM_ALREADYSET, 3, comps_str("optionlist"), comps_num(1244), comps_num(4)); parsed = comps_parse_parsed_create(); comps_parse_parsed_init(parsed, "UTF-8", 1); fp = fopen("sample_comps_bad2.xml", "r"); comps_parse_file(parsed, fp, NULL); fail_if(parsed->log->entries->first == NULL); check_errors(parsed->log, known_errors, 15); for (i = 0; i < 15; i++) { comps_log_entry_destroy(known_errors[i]); } comps_parse_parsed_destroy(parsed); }
COMPS_Object* comps_docgroupid_get_default(COMPS_DocGroupId *gid) { return (COMPS_Object*)comps_num(gid->def); }
COMPS_Object* comps_docpackage_get_type(COMPS_DocGroupPackage *pkg) { return (COMPS_Object*)comps_num(pkg->type); }