X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Falternative-test.c;h=b3ee4e9eb020db3ab4dbf5f3c6caecf3805fc2d0;hb=511bbee5e4da8e71b5da8521a162941398ebfdba;hp=9e26d245a41c7f90931ce7736bf7b994cbce90fa;hpb=c5544522f6409095627dc3d1129560195ab4ec40;p=catta diff --git a/avahi-common/alternative-test.c b/avahi-common/alternative-test.c index 9e26d24..b3ee4e9 100644 --- a/avahi-common/alternative-test.c +++ b/avahi-common/alternative-test.c @@ -26,23 +26,60 @@ #include #include "alternative.h" +#include "malloc.h" -int main(int argc, char *argv[]) { - gchar *r = NULL; - gint i, k; +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + const char* const test_strings[] = { + "gurke", + "", + "-", + " #", + "1", + "#0", + " #0", + " #1", + "#-1", + " #-1", + "-0", + "--0", + "-1", + "--1", + "-2", + "gurke1", + "gurke0", + "gurke-2", + "gurke #0", + "gurke #1", + "gurke #", + "gurke#1", + "gurke-", + "gurke---", + "gurke #", + "gurke ###", + NULL + }; + + char *r = NULL; + int i, j, k; + + for (k = 0; test_strings[k]; k++) { - for (k = 0; k < 2; k++) { + printf(">>>>>%s<<<<\n", test_strings[k]); + + for (j = 0; j < 2; j++) { - for (i = 0; i < 20; i++) { - gchar *n; - - n = i == 0 ? g_strdup("gurke") : (k ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r)); - g_free(r); - r = n; - - printf("%s\n", r); + for (i = 0; i < 20; i++) { + char *n; + + n = i == 0 ? avahi_strdup(test_strings[k]) : (j ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r)); + avahi_free(r); + r = n; + + printf("%s\n", r); + } } } - g_free(r); + avahi_free(r); + return 0; }