1 /* t-stringhelp.c - Regression tests for stringhelp.c
2 * Copyright (C) 2007 Free Software Foundation, Inc.
4 * This file is part of JNLIB.
6 * JNLIB is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * JNLIB is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include "stringhelp.h"
27 #include "t-support.h"
32 test_percent_escape (void)
43 { NULL
, "%%", "%25%25" },
44 { NULL
, " %", " %25" },
46 { NULL
, " :", " %3a" },
47 { NULL
, ": ", "%3a " },
48 { NULL
, " : ", " %3a " },
49 { NULL
, "::", "%3a%3a" },
50 { NULL
, ": :", "%3a %3a" },
51 { NULL
, "%:", "%25%3a" },
52 { NULL
, ":%", "%3a%25" },
53 { "\\\n:", ":%", "%3a%25" },
54 { "\\\n:", "\\:%", "%5c%3a%25" },
55 { "\\\n:", "\n:%", "%0a%3a%25" },
56 { "\\\n:", "\xff:%", "\xff%3a%25" },
57 { "\\\n:", "\xfe:%", "\xfe%3a%25" },
58 { "\\\n:", "\x01:%", "\x01%3a%25" },
59 { "\x01", "\x01:%", "%01%3a%25" },
60 { "\xfe", "\xfe:%", "%fe%3a%25" },
61 { "\xfe", "\xff:%", "\xff%3a%25" },
67 result
= percent_escape (NULL
, NULL
);
70 for (testno
=0; tests
[testno
].value
; testno
++)
72 result
= percent_escape (tests
[testno
].value
, tests
[testno
].extra
);
75 if (strcmp (result
, tests
[testno
].expected
))
84 test_compare_filenames (void)
99 #ifdef HAVE_W32_SYSTEM
102 { "foo/bar", "foo\\bar", 0 },
103 { "foo\\bar", "foo/bar", 0 },
104 { "foo\\", "foo/", 0 },
105 { "foo/", "foo\\", 0 },
106 #endif /*HAVE_W32_SYSTEM*/
111 for (testno
=0; tests
[testno
].a
; testno
++)
113 result
= compare_filenames (tests
[testno
].a
, tests
[testno
].b
);
114 result
= result
< 0? -1 : result
> 0? 1 : 0;
115 if (result
!= tests
[testno
].result
)
122 main (int argc
, char **argv
)
127 test_percent_escape ();
128 test_compare_filenames ();