Home | Info | Community | Development | myReactOS | Contact Us
[static]
Definition at line 149 of file testdict.c.
Referenced by run_test1().
{ int i, j; xmlDictPtr dict; int ret = 0; xmlChar prefix[40]; xmlChar *cur, *pref; const xmlChar *tmp; dict = xmlDictCreateSub(parent); if (dict == NULL) { fprintf(stderr, "Out of memory while creating sub-dictionary\n"); exit(1); } memset(test2, 0, sizeof(test2)); /* * Fill in NB_STRINGS_MIN, at this point the dictionary should not grow * and we allocate all those doing the fast key computations * All the strings are based on a different seeds subset so we know * they are allocated in the main dictionary, not coming from the parent */ for (i = 0;i < NB_STRINGS_MIN;i++) { test2[i] = xmlDictLookup(dict, strings2[i], -1); if (test2[i] == NULL) { fprintf(stderr, "Failed lookup for '%s'\n", strings2[i]); ret = 1; nbErrors++; } } j = NB_STRINGS_MAX - NB_STRINGS_NS; /* ":foo" like strings2 */ for (i = 0;i < NB_STRINGS_MIN;i++, j++) { test2[j] = xmlDictLookup(dict, strings2[j], xmlStrlen(strings2[j])); if (test2[j] == NULL) { fprintf(stderr, "Failed lookup for '%s'\n", strings2[j]); ret = 1; nbErrors++; } } /* "a:foo" like strings2 */ j = NB_STRINGS_MAX - NB_STRINGS_MIN; for (i = 0;i < NB_STRINGS_MIN;i++, j++) { test2[j] = xmlDictLookup(dict, strings2[j], xmlStrlen(strings2[j])); if (test2[j] == NULL) { fprintf(stderr, "Failed lookup for '%s'\n", strings2[j]); ret = 1; nbErrors++; } } /* * At this point allocate all the strings * the dictionary will grow in the process, reallocate more string tables * and switch to the better key generator */ for (i = 0;i < NB_STRINGS_MAX;i++) { if (test2[i] != NULL) continue; test2[i] = xmlDictLookup(dict, strings2[i], -1); if (test2[i] == NULL) { fprintf(stderr, "Failed lookup for '%s'\n", strings2[i]); ret = 1; nbErrors++; } } /* * Now we can start to test things, first that all strings2 belongs to * the dict, and that none of them was actually allocated in the parent */ for (i = 0;i < NB_STRINGS_MAX;i++) { if (!xmlDictOwns(dict, test2[i])) { fprintf(stderr, "Failed ownership failure for '%s'\n", strings2[i]); ret = 1; nbErrors++; } if (xmlDictOwns(parent, test2[i])) { fprintf(stderr, "Failed parent ownership failure for '%s'\n", strings2[i]); ret = 1; nbErrors++; } } /* * Also verify that all strings from the parent are seen from the subdict */ for (i = 0;i < NB_STRINGS_MAX;i++) { if (!xmlDictOwns(dict, test1[i])) { fprintf(stderr, "Failed sub-ownership failure for '%s'\n", strings1[i]); ret = 1; nbErrors++; } } /* * Then that another lookup to the string in sub will return the same */ for (i = 0;i < NB_STRINGS_MAX;i++) { if (xmlDictLookup(dict, strings2[i], -1) != test2[i]) { fprintf(stderr, "Failed re-lookup check for %d, '%s'\n", i, strings2[i]); ret = 1; nbErrors++; } } /* * But also that any lookup for a string in the parent will be provided * as in the parent */ for (i = 0;i < NB_STRINGS_MAX;i++) { if (xmlDictLookup(dict, strings1[i], -1) != test1[i]) { fprintf(stderr, "Failed parent string lookup check for %d, '%s'\n", i, strings1[i]); ret = 1; nbErrors++; } } /* * check the QName lookups */ for (i = NB_STRINGS_MAX - NB_STRINGS_NS;i < NB_STRINGS_MAX;i++) { cur = strings2[i]; pref = &prefix[0]; while (*cur != ':') *pref++ = *cur++; cur++; *pref = 0; tmp = xmlDictQLookup(dict, &prefix[0], cur); if (xmlDictQLookup(dict, &prefix[0], cur) != test2[i]) { fprintf(stderr, "Failed lookup check for '%s':'%s'\n", &prefix[0], cur); ret = 1; nbErrors++; } } /* * check the QName lookups for strings from the parent */ for (i = NB_STRINGS_MAX - NB_STRINGS_NS;i < NB_STRINGS_MAX;i++) { cur = strings1[i]; pref = &prefix[0]; while (*cur != ':') *pref++ = *cur++; cur++; *pref = 0; tmp = xmlDictQLookup(dict, &prefix[0], cur); if (xmlDictQLookup(dict, &prefix[0], cur) != test1[i]) { fprintf(stderr, "Failed parent lookup check for '%s':'%s'\n", &prefix[0], cur); ret = 1; nbErrors++; } } xmlDictFree(dict); return(ret); }