Skip to content

Commit

Permalink
added t/04
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Feb 8, 2016
1 parent 9dec4d6 commit ef064c5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions t/04-filter.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/perl
use warnings;
use strict;

use Data::Dumper;
use Test::More;
use WWW::FreeProxyListsCom;

my $p = WWW::FreeProxyListsCom->new;

my $ca = $p->get_list(type => 'ca');

my $all = $p->filter;
is (@$ca, @$all, "no filter results in entire list");

my $canada = $p->filter(country => 'Canada');
is (@$canada, @$all, "country filter results in proper count");

my $ip = $ca->[0]->{ip};
my $ip_check = @{ $p->filter(ip => $ip) };
is ($ip_check, 1, "IP filter count is ok");

my $port_count;
for my $prox (@$ca){
$port_count++ if $prox->{port} eq '3128';
}
is (@{ $p->filter(port => '3128') }, $port_count, "string port filter ok");

$port_count = 0;
for my $prox (@$ca){
$port_count++ if $prox->{port} == 3128;
}
is (@{ $p->filter(port => 3128) }, $port_count, "numeric port filter ok");

my $latency = $p->filter(latency => qr/^\d{3}$/);
ok (scalar @$latency < scalar @$ca, "latency filter has less entries than all");

my $last_test = $p->filter(last_test => qr/am/);
ok (scalar @$last_test < scalar @$ca, "last_test filter works");

my $http = $p->filter(is_https => 'false');
my $https = $p->filter(is_https => 'true');
ok (scalar @$http < scalar @$ca, "is_http filter works for false");
ok (scalar @$https < scalar @$ca, "is_http filter works for true");

done_testing();

0 comments on commit ef064c5

Please sign in to comment.