Debian Codegraph @

lemonldap-ng-common/t/36-Common-Regexp.t

raw
1 use warnings;
2
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl Lemonldap-NG-Common.t'
5
6 #########################
7
8 # change 'tests => 1' to 'tests => last_test_to_print';
9
10 use Test::More tests => 20;
11 use strict;
12
13 BEGIN {
14 use_ok('Lemonldap::NG::Common::Regexp');
15 }
16
17 #########################
18
19 # Insert your test code below, the Test::More module is used here so read
20 # its man page ( perldoc Test::More ) for help writing this test script.
21
22 *HOST = *Lemonldap::NG::Common::Regexp::HOST;
23 *HOSTNAME = *Lemonldap::NG::Common::Regexp::HOSTNAME;
24 *HTTP_URI = *Lemonldap::NG::Common::Regexp::HTTP_URI;
25 *reDomainsToHost = *Lemonldap::NG::Common::Regexp::reDomainsToHost;
26
27 ok( 'test.ex.com' =~ HOST() );
28 ok( 'test.ex.com' =~ HOSTNAME() );
29 ok( 'test..ex.com' !~ HOST() );
30 ok( 'test..ex.com' !~ HOSTNAME() );
31 ok( '10.1.1.1' =~ HOST() );
32 ok( '10.1.1.1' !~ HOSTNAME() );
33 ok( 'test.ex.com' !~ HTTP_URI() );
34 ok( 'https://test.ex.com' =~ HTTP_URI() );
35 ok( 'https://test.ex.com/' =~ HTTP_URI() );
36 ok( 'https://test.ex.com/a' =~ HTTP_URI() );
37 ok( 'https://test.ex.com/?<script>' !~ HTTP_URI() );
38
39 my $re;
40 ok( $re = reDomainsToHost('a.com b.org c.net') );
41 ok( 'test.d.fr' !~ $re );
42
43 foreach (qw(a.com b.org c.net)) {
44 ok( "test.$_" =~ $re );
45 ok( "test..$_" !~ $re );
46 }