2 * Copyright (c) 2000 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
10 #pragma ident "%Z%%M% %I% %E% SMI"
13 SM_IDSTR(id
, "@(#)$Id: t-match.c,v 1.7 2000/12/18 18:12:12 ca Exp $")
15 #include <sm/string.h>
19 #define try(str, pat, want) \
20 got = sm_match(str, pat); \
21 if (!SM_TEST(got == want)) \
22 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, \
23 "sm_match(\"%s\", \"%s\") returns %s\n", \
24 str, pat, got ? "true" : "false");
33 sm_test_begin(argc
, argv
, "test sm_match");
35 try("foo", "foo", true);
36 try("foo", "bar", false);
37 try("foo[bar", "foo[bar", true);
38 try("foo[bar]", "foo[bar]", false);
39 try("foob", "foo[bar]", true);
40 try("a-b", "a[]-]b", true);
41 try("abcde", "a*e", true);
42 try("[", "[[]", true);
43 try("c", "[a-z]", true);
44 try("C", "[a-z]", false);
45 try("F:sm.heap", "[!F]*", false);
46 try("E:sm.err", "[!F]*", true);