140266059SGregory Neil Shapiro /* 25dd76dd0SGregory Neil Shapiro * Copyright (c) 2000 Proofpoint, Inc. and its suppliers. 340266059SGregory Neil Shapiro * All rights reserved. 440266059SGregory Neil Shapiro * 540266059SGregory Neil Shapiro * By using this file, you agree to the terms and conditions set 640266059SGregory Neil Shapiro * forth in the LICENSE file which can be found at the top level of 740266059SGregory Neil Shapiro * the sendmail distribution. 840266059SGregory Neil Shapiro */ 940266059SGregory Neil Shapiro 1040266059SGregory Neil Shapiro #include <sm/gen.h> 11*4313cc83SGregory Neil Shapiro SM_IDSTR(id, "@(#)$Id: t-match.c,v 1.10 2013-11-22 20:51:43 ca Exp $") 1240266059SGregory Neil Shapiro 1340266059SGregory Neil Shapiro #include <sm/string.h> 1440266059SGregory Neil Shapiro #include <sm/io.h> 1540266059SGregory Neil Shapiro #include <sm/test.h> 1640266059SGregory Neil Shapiro 1740266059SGregory Neil Shapiro #define try(str, pat, want) \ 1840266059SGregory Neil Shapiro got = sm_match(str, pat); \ 1940266059SGregory Neil Shapiro if (!SM_TEST(got == want)) \ 2040266059SGregory Neil Shapiro (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, \ 2140266059SGregory Neil Shapiro "sm_match(\"%s\", \"%s\") returns %s\n", \ 2240266059SGregory Neil Shapiro str, pat, got ? "true" : "false"); 2340266059SGregory Neil Shapiro 2440266059SGregory Neil Shapiro int 2540266059SGregory Neil Shapiro main(argc, argv) 2640266059SGregory Neil Shapiro int argc; 2740266059SGregory Neil Shapiro char **argv; 2840266059SGregory Neil Shapiro { 2940266059SGregory Neil Shapiro bool got; 3040266059SGregory Neil Shapiro 3140266059SGregory Neil Shapiro sm_test_begin(argc, argv, "test sm_match"); 3240266059SGregory Neil Shapiro 3340266059SGregory Neil Shapiro try("foo", "foo", true); 3440266059SGregory Neil Shapiro try("foo", "bar", false); 3540266059SGregory Neil Shapiro try("foo[bar", "foo[bar", true); 3640266059SGregory Neil Shapiro try("foo[bar]", "foo[bar]", false); 3740266059SGregory Neil Shapiro try("foob", "foo[bar]", true); 3840266059SGregory Neil Shapiro try("a-b", "a[]-]b", true); 3940266059SGregory Neil Shapiro try("abcde", "a*e", true); 4040266059SGregory Neil Shapiro try("[", "[[]", true); 4140266059SGregory Neil Shapiro try("c", "[a-z]", true); 4240266059SGregory Neil Shapiro try("C", "[a-z]", false); 4340266059SGregory Neil Shapiro try("F:sm.heap", "[!F]*", false); 4440266059SGregory Neil Shapiro try("E:sm.err", "[!F]*", true); 4540266059SGregory Neil Shapiro 4640266059SGregory Neil Shapiro return sm_test_end(); 4740266059SGregory Neil Shapiro } 48