Back to index

glibc  2.9
tst-fnmatch2.c
Go to the documentation of this file.
00001 #include <fnmatch.h>
00002 #include <stdio.h>
00003 
00004 int
00005 do_test (void)
00006 {
00007   char pattern[] = "a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*";
00008   const char *string = "aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmm"
00009                      "nnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyy";
00010   if (fnmatch (pattern, string, 0) != FNM_NOMATCH)
00011     {
00012       puts ("First fnmatch didn't return FNM_NOMATCH");
00013       return 1;
00014     }
00015   pattern[(sizeof pattern) - 3] = '*';
00016   if (fnmatch (pattern, string, 0) != 0)
00017     {
00018       puts ("Second fnmatch didn't return 0");
00019       return 1;
00020     }
00021   if (fnmatch ("a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD) != FNM_NOMATCH)
00022     {
00023       puts ("Third fnmatch didn't return FNM_NOMATCH");
00024       return 1;
00025     }
00026   if (fnmatch ("a*b/*", "abbb/xy", FNM_PATHNAME | FNM_PERIOD) != 0)
00027     {
00028       puts ("Fourth fnmatch didn't return 0");
00029       return 1;
00030     }
00031   return 0;
00032 }
00033 
00034 #define TEST_FUNCTION do_test ()
00035 #include "../test-skeleton.c"