[libnet-openid-common-perl] 05/34: Add tests comparing 'eq' to OpenID::util::timing_indep_eq()

gregor herrmann gregoa at debian.org
Sun Feb 7 21:50:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to annotated tag v1.030099_001
in repository libnet-openid-common-perl.

commit 25f50835ed07c6256509674ac4849b6211cad232
Author: Adam Sjøgren <asjo at koldfront.dk>
Date:   Mon Aug 9 11:41:07 2010 +0200

    Add tests comparing 'eq' to OpenID::util::timing_indep_eq()
---
 t/05-eq.t | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/t/05-eq.t b/t/05-eq.t
new file mode 100644
index 0000000..15a0db2
--- /dev/null
+++ b/t/05-eq.t
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+use strict;
+use utf8;
+
+use Test::More tests=>14;
+
+use Net::OpenID::Common;
+
+compare_comparisons('x', 'x', 'same, 1 char');
+compare_comparisons('x', 'y', 'different, 1 char');
+
+compare_comparisons('xx', 'xx', 'same, 2 chars');
+compare_comparisons('xx', 'xy', 'different, 2 chars');
+
+compare_comparisons('Frække frølår', 'Frække frølår', 'same, utf-8');
+compare_comparisons('Frøkke frålær', 'Frække frølår', 'different, utf-8');
+
+my $x='x' x 1,000,000;
+my $y='y' . 'x' x 999,999;
+compare_comparisons($x, $x, 'same, 1M chars');
+compare_comparisons($x, $y, 'different, 1M chars');
+
+my $z='x' x 999,999;
+compare_comparisons( $x,   $z, 'different lengths, long');
+compare_comparisons('a', 'aa', 'different lengths, short');
+compare_comparisons( '',  'a', 'different lengths, shortest');
+
+compare_comparisons( '',  '', 'same length, shortest');
+
+compare_comparisons(undef,  '', 'undef, empty string');
+compare_comparisons(undef, undef, 'both undef');
+
+1;
+
+sub compare_comparisons {
+    my ($first, $second, $description)=@_;
+
+    is( ($first eq $second), OpenID::util::timing_indep_eq($first, $second), $description);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-openid-common-perl.git



More information about the Pkg-perl-cvs-commits mailing list