~ubuntu-branches/ubuntu/quantal/libnet-openid-common-perl/quantal

« back to all changes in this revision

Viewing changes to t/05-eq.t

  • Committer: Package Import Robot
  • Author(s): Dominic Hargreaves
  • Date: 2011-11-11 22:07:41 UTC
  • Revision ID: package-import@ubuntu.com-20111111220741-duf8dtmvkh2jiiwm
Tags: upstream-1.14
Import upstream version 1.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use warnings;
 
4
use strict;
 
5
use utf8;
 
6
 
 
7
use Test::More tests=>14;
 
8
 
 
9
use Net::OpenID::Common;
 
10
 
 
11
compare_comparisons('x', 'x', 'same, 1 char');
 
12
compare_comparisons('x', 'y', 'different, 1 char');
 
13
 
 
14
compare_comparisons('xx', 'xx', 'same, 2 chars');
 
15
compare_comparisons('xx', 'xy', 'different, 2 chars');
 
16
 
 
17
compare_comparisons('Frække frølår', 'Frække frølår', 'same, utf-8');
 
18
compare_comparisons('Frøkke frålær', 'Frække frølår', 'different, utf-8');
 
19
 
 
20
my $x='x' x 1000000;
 
21
my $y='y' . 'x' x 999999;
 
22
compare_comparisons($x, $x, 'same, 1M chars');
 
23
compare_comparisons($x, $y, 'different, 1M chars');
 
24
 
 
25
my $z='x' x 999999;
 
26
compare_comparisons( $x,   $z, 'different lengths, long');
 
27
compare_comparisons('a', 'aa', 'different lengths, short');
 
28
compare_comparisons( '',  'a', 'different lengths, shortest');
 
29
 
 
30
compare_comparisons( '',  '', 'same length, shortest');
 
31
 
 
32
compare_comparisons(undef,  '', 'undef, empty string');
 
33
compare_comparisons(undef, undef, 'both undef');
 
34
 
 
35
1;
 
36
 
 
37
sub compare_comparisons {
 
38
    my ($first, $second, $description)=@_;
 
39
 
 
40
    # XXX may still want to test that the circumstances under
 
41
    # which eq and timing_indep_eq produce warnings are the same
 
42
 
 
43
    no warnings 'uninitialized';
 
44
    is( ($first eq $second),
 
45
        OpenID::util::timing_indep_eq($first, $second),
 
46
        $description);
 
47
}