]> git.meshlink.io Git - catta/blob - avahi/alternative-test.c
remove a left-over reference to boostrap.sh and autogen.sh
[catta] / avahi / alternative-test.c
1 /***
2   This file is part of avahi.
3
4   avahi is free software; you can redistribute it and/or modify it
5   under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2.1 of the
7   License, or (at your option) any later version.
8
9   avahi is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12   Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with avahi; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA.
18 ***/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <stdio.h>
25
26 #include "alternative.h"
27 #include "malloc.h"
28 #include "domain.h"
29
30 int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
31     const char* const test_strings[] = {
32         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
33         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXüüüüüüü",
34         "gurke",
35         "-",
36         " #",
37         "1",
38         "#0",
39         " #0",
40         " #1",
41         "#-1",
42         " #-1",
43         "-0",
44         "--0",
45         "-1",
46         "--1",
47         "-2",
48         "gurke1",
49         "gurke0",
50         "gurke-2",
51         "gurke #0",
52         "gurke #1",
53         "gurke #",
54         "gurke#1",
55         "gurke-",
56         "gurke---",
57         "gurke #",
58         "gurke ###",
59         NULL
60     };
61
62     char *r = NULL;
63     int i, j, k;
64
65     for (k = 0; test_strings[k]; k++) {
66
67         printf(">>>>>%s<<<<\n", test_strings[k]);
68
69         for (j = 0; j < 2; j++) {
70
71             for (i = 0; i <= 100; i++) {
72                 char *n;
73
74                 n = i == 0 ? avahi_strdup(test_strings[k]) : (j ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r));
75                 avahi_free(r);
76                 r = n;
77
78                 if (j)
79                     assert(avahi_is_valid_service_name(n));
80                 else
81                     assert(avahi_is_valid_host_name(n));
82
83                 printf("%s\n", r);
84             }
85         }
86     }
87
88     avahi_free(r);
89     return 0;
90 }