Non-VMS-fixed and Win32-skipped version of
[p5sagit/p5-mst-13.2.git] / t / op / crypt.t
index 26eb06a..8beb41d 100644 (file)
@@ -1,4 +1,22 @@
-use Test::More tests => 2;
+#!./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 => 2);
+    }
+}
 
 # Can't assume too much about the string returned by crypt(),
 # and about how many bytes of the encrypted (really, hashed)
@@ -10,6 +28,6 @@ use Test::More tests => 2;
 # bets, given alternative encryption/hashing schemes like MD5,
 # C2 (or higher) security schemes, and non-UNIX platforms.
 
-ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt");
+ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt makes a difference");
 
-ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode");
+ok(crypt("HI", "HO") eq crypt(join("",map{chr($_+256)}unpack"C*","HI"), "HO"), "low eight bits of Unicode");