X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fcrypt.t;h=27c878f1bd5d3a01f512ba3df917201cc621aefa;hb=b36bdecab13f885c556206f71bfc47083b33107e;hp=2619338b25c0108689227553f72248e05ec65e1f;hpb=17f79ebbbd3973522217b30539c665cfc7641376;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/crypt.t b/t/op/crypt.t index 2619338..27c878f 100644 --- a/t/op/crypt.t +++ b/t/op/crypt.t @@ -1,5 +1,22 @@ -use Test::More tests => 2; -use Config; +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = qw(. ../lib); +} + +BEGIN { + use Config; + + require "test.pl"; + + if( !$Config{d_crypt} ) { + skip_all("crypt unimplemented"); + } + else { + plan(tests => 4); + } +} # Can't assume too much about the string returned by crypt(), # and about how many bytes of the encrypted (really, hashed) @@ -12,9 +29,18 @@ use Config; # C2 (or higher) security schemes, and non-UNIX platforms. SKIP: { - skip "crypt unimplemented", 2, unless $Config{d_crypt}; - - ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt"); - - ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode"); + skip ("VOS crypt ignores salt.", 1) if ($^O eq 'vos'); + ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt makes a difference"); } + +$a = "a\xFF\x{100}"; + +eval {$b = crypt($a, "cd")}; +like($@, qr/Wide character in crypt/, "wide characters ungood"); + +chop $a; # throw away the wide character + +eval {$b = crypt($a, "cd")}; +is($@, '', "downgrade to eight bit characters"); +is($b, crypt("a\xFF", "cd"), "downgrade results agree"); +