@@ -, +, @@ prove -v t/db_dependent/Holds.t --------- -- This should generate the uninitialized string warnings. Make sure CPL and MPL are in your branches to save yourself from headaches due to expected data. -- note there are no function calls to NormalizeString. You can see other shortfalls in the tests beyond NormalizeString with: grep ^sub C4/Charset.pm -- Run as before with more tests. -- note there are now function calls to NormalizeString. -- Nice and clean run! :) -- all should be Ok. --- C4/Charset.pm | 1 + t/Charset.t | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) --- a/C4/Charset.pm +++ a/C4/Charset.pm @@ -178,6 +178,7 @@ Sample code : sub NormalizeString{ my ($string,$nfd,$transform)=@_; + return $string unless defined($string); # force scalar context return. utf8::decode($string) unless (utf8::is_utf8($string)); if ($nfd){ $string= NFD($string); --- a/t/Charset.t +++ a/t/Charset.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 16; use MARC::Record; use utf8; @@ -27,6 +27,15 @@ BEGIN { use_ok('C4::Charset'); } +my $string; +ok(!defined(NormalizeString($string,undef,1)),'Uninitialized string case 1 normalizes to uninitialized string.'); + +$string = 'Sample'; +ok(defined(NormalizeString($string,undef,0)), 'Initialized string case 1 normalizes to some string.'); +ok(defined(NormalizeString($string,undef,1)), 'Initialized string case 2 normalizes to some string.'); +ok(defined(NormalizeString($string,1,0)), 'Initialized string case 3 normalizes to some string.'); +ok(defined(NormalizeString($string,1,1)), 'Initialized string case 4 normalizes to some string.'); + my $octets = "abc"; ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)"); --