Merge commit 'a39d4083cab589d7cd6a13e8a4b8db8875261d75'
[gnulib.git] / tests / test-fnmatch.c
index f9485af..de94559 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of fnmatch string matching function.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "signature.h"
 SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int));
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr)                                                    \
-  do                                                                    \
-    {                                                                   \
-      if (!(expr))                                                      \
-        {                                                               \
-          fprintf (stderr, "%s:%d: assertion failed\n",                 \
-                   __FILE__, __LINE__);                                 \
-          fflush (stderr);                                              \
-          abort ();                                                     \
-        }                                                               \
-    }                                                                   \
-  while (0)
+#include "macros.h"
 
 int
 main ()
@@ -60,5 +46,11 @@ main ()
   ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", 0) == 0);
   ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH);
 
+  /* Verify that an unmatched [ is treated as a literal, as POSIX
+     requires.  This test ensures that glibc Bugzilla bug #12378 stays
+     fixed.
+   */
+  ASSERT (res = fnmatch ("[/b", "[/b", 0) == 0);
+
   return 0;
 }