From cdda20fb18473c4a35a59d5c4a13cbc7b5d1c678 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 21 Mar 2011 20:28:25 -0500 Subject: [PATCH] add better diag and fix test. I think OSX is altering the UTF-8 chars to a different codepoint on me. --- t/Storage/utf8_filenames.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/Storage/utf8_filenames.t b/t/Storage/utf8_filenames.t index d843258a2..ad00d39f7 100644 --- a/t/Storage/utf8_filenames.t +++ b/t/Storage/utf8_filenames.t @@ -10,6 +10,7 @@ #The goal of this test is to checkout uft8 handling in filenames. +use utf8; use FindBin; use strict; use lib "$FindBin::Bin/..//lib"; @@ -47,7 +48,7 @@ cmp_deeply( 'getFiles: returns names in UTF-8' ); -my $copy_name = "Ca\x{00F1}on.txt"; +my $copy_name = "Ca\x{0303}on.txt"; utf8::upgrade($copy_name); $filesystem_storage->copyFile($filename, $copy_name); @@ -55,4 +56,19 @@ cmp_bag( $filesystem_storage->getFiles(), [ $filename, $copy_name ], 'copyFile: copies files handling UTF-8 correctly' +) +or diag( + "GOT: " . join( ', ', map { nice_string($_) } @{ $filesystem_storage->getFiles } ) + . " EXPECT: " . join( ', ', map { nice_string($_) } ( $filename, $copy_name ) ) ); + +sub nice_string { + join("", + map { $_ > 255 ? # if wide character... + sprintf('\\x{%04X}', $_) : # \x{...} + chr($_) =~ /[[:cntrl:]]/ ? # else if control character ... + sprintf('\\x%02X', $_) : # \x.. + quotemeta(chr($_)) # else quoted or as themselves + } unpack("W*", $_[0])); # unpack Unicode characters +} +