aboutsummaryrefslogtreecommitdiffstats
path: root/jnlib/t-stringhelp.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2007-08-02 18:12:43 +0000
committerWerner Koch <[email protected]>2007-08-02 18:12:43 +0000
commitebd36b634450ce9fdf0104052cca2b035ad3a22d (patch)
tree1708507fee17d3520460bd94636800d4b828c8ed /jnlib/t-stringhelp.c
parentApplied exact length hack. (diff)
downloadgnupg-ebd36b634450ce9fdf0104052cca2b035ad3a22d.tar.gz
gnupg-ebd36b634450ce9fdf0104052cca2b035ad3a22d.zip
Factored common gpgconf constants out
Fixed W32 compare_filenames
Diffstat (limited to 'jnlib/t-stringhelp.c')
-rw-r--r--jnlib/t-stringhelp.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/jnlib/t-stringhelp.c b/jnlib/t-stringhelp.c
index 89ba643bf..12331d241 100644
--- a/jnlib/t-stringhelp.c
+++ b/jnlib/t-stringhelp.c
@@ -80,12 +80,49 @@ test_percent_escape (void)
}
+static void
+test_compare_filenames (void)
+{
+ struct {
+ const char *a;
+ const char *b;
+ int result;
+ } tests[] = {
+ { "", "", 0 },
+ { "", "a", -1 },
+ { "a", "", 1 },
+ { "a", "a", 0 },
+ { "a", "aa", -1 },
+ { "aa", "a", 1 },
+ { "a", "b", -1 },
+
+#ifdef HAVE_W32_SYSTEM
+ { "a", "A", 0 },
+ { "A", "a", 0 },
+ { "foo/bar", "foo\\bar", 0 },
+ { "foo\\bar", "foo/bar", 0 },
+ { "foo\\", "foo/", 0 },
+ { "foo/", "foo\\", 0 },
+#endif /*HAVE_W32_SYSTEM*/
+ { NULL, NULL, 0}
+ };
+ int testno, result;
+
+ for (testno=0; tests[testno].a; testno++)
+ {
+ result = compare_filenames (tests[testno].a, tests[testno].b);
+ result = result < 0? -1 : result > 0? 1 : 0;
+ if (result != tests[testno].result)
+ fail (testno);
+ }
+}
int
main (int argc, char **argv)
{
test_percent_escape ();
+ test_compare_filenames ();
return 0;
}