2 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 # Use is subject to license terms.
7 # The contents of this file are subject to the terms of the
8 # Common Development and Distribution License, Version 1.0 only
9 # (the "License"). You may not use this file except in compliance
12 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 # or http://www.opensolaris.org/os/licensing.
14 # See the License for the specific language governing permissions
15 # and limitations under the License.
17 # When distributing Covered Code, include this CDDL HEADER in each
18 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 # If applicable, add the following below this CDDL HEADER, with the
20 # fields enclosed by brackets "[]" replaced with your own identifying
21 # information: Portions Copyright [yyyy] [name of copyright owner]
25 #ident "%Z%%M% %I% %E% SMI"
27 # test script for Sun::Solaris::Utils gmatch()
32 BEGIN { $| = 1; print "1..49\n"; }
34 END {print "not ok 1\n" unless $loaded;}
35 use Sun::Solaris::Utils qw(gmatch);
42 my @strs = ( 'a', 'aa', 'z', 'zz', '0', '0123456789' );
44 { pattern => 'a', results => [ 1, 0, 0, 0, 0, 0 ] },
45 { pattern => '*', results => [ 1, 1, 1, 1, 1, 1 ] },
46 { pattern => '?', results => [ 1, 0, 1, 0, 1, 0 ] },
47 { pattern => '??', results => [ 0, 1, 0, 1, 0, 0 ] },
48 { pattern => '[a-z]*', results => [ 1, 1, 1, 1, 0, 0 ] },
49 { pattern => '[!a-z]*', results => [ 0, 0, 0, 0, 1, 1 ] },
50 { pattern => '[0-9]*', results => [ 0, 0, 0, 0, 1, 1 ] },
51 { pattern => '[!0-9]*', results => [ 1, 1, 1, 1, 0, 0 ] },
54 foreach my $t (@tests) {
55 for (my $i = 0; $i < @strs; $i++) {
56 if (gmatch($strs[$i], $t->{pattern}) == $t->{results}[$i]) {
59 print("not ok $test\n");