mvhub-dev team mailing list archive
-
mvhub-dev team
-
Mailing list archive
-
Message #00259
[Merge] lp:~omacneil/mvhub/add_procedural_unit_tests into lp:mvhub
Dan MacNeil has proposed merging lp:~omacneil/mvhub/add_procedural_unit_tests into lp:mvhub.
Requested reviews:
MVHub devs with commit rights (mvhub-commit)
fixed bug discovered with new test data
added tests to move Utils.pm closer to 100% test coverage
--
https://code.launchpad.net/~omacneil/mvhub/add_procedural_unit_tests/+merge/27096
Your team MVHub Developers is subscribed to branch lp:mvhub.
=== modified file 'lib-mvhub/lib/MVHub/Common.pm'
--- lib-mvhub/lib/MVHub/Common.pm 2010-03-31 16:11:24 +0000
+++ lib-mvhub/lib/MVHub/Common.pm 2010-06-08 23:45:38 +0000
@@ -33,7 +33,6 @@
prepare_form
print_page_and_exit
sendmail
- undelimit_field
);
our ($VERSION) = '$Revision: 1729 $' =~ /([.\d]+)/;
=== modified file 'lib-mvhub/lib/MVHub/Utils.pm'
--- lib-mvhub/lib/MVHub/Utils.pm 2010-05-07 17:02:45 +0000
+++ lib-mvhub/lib/MVHub/Utils.pm 2010-06-08 23:45:38 +0000
@@ -142,6 +142,9 @@
my $value = shift;
return $value if !defined $value;
+ # fix problems caused by trailing DELEM
+ $value=~s/(.*)!DELIM!$/$1/;
+
my $FIELD_DELIMITER = '!DELIM!';
my @split = split( /$FIELD_DELIMITER/, $value );
=== added file 'lib-mvhub/t/Utils/undelimit_field.t'
--- lib-mvhub/t/Utils/undelimit_field.t 1970-01-01 00:00:00 +0000
+++ lib-mvhub/t/Utils/undelimit_field.t 2010-06-08 23:45:38 +0000
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+
+# $Revision: 1141 $
+# $Source$
+
+use strict;
+# use Test::More tests => 4 +1; # +1 for NoWarnings;
+use Test::More tests => 6 +1; # +1 for NoWarnings;
+use Test::NoWarnings;
+use MVHub::Utils qw/undelimit_field/;
+
+my ( $in, $out, $test_name ,$got,$expected);
+
+######
+$test_name = 'input is not defined';
+
+$in=undef;
+$expected=undef;
+$got=undelimit_field($in);
+is ($got,$expected,$test_name);
+
+######
+$test_name = 'input has no elements';
+
+$in="";
+$expected="";
+$got=undelimit_field($in);
+is ($got,$expected,$test_name);
+
+######
+$test_name = 'input > 1 element returned array ref';
+
+$in='a!DELIM! b!DELIM!';
+$got=undelimit_field($in);
+ok(ref $got eq 'ARRAY',$test_name);
+
+#####
+$test_name = 'input has 1 element and no !DELIM!';
+
+$in="a";
+$expected="a";
+$got=undelimit_field($in);
+is ($got,$expected,$test_name);
+
+######
+$test_name = 'input has 2 element with (1) !DELIM!';
+
+$in='a!DELIM!b';
+$got=undelimit_field($in);
+$expected = ['a','b'];
+is_deeply($got,$expected,$test_name);
+
+######
+$test_name = 'input has 1 element with (1) !DELIM!';
+
+$in='a!DELIM!';
+$got=undelimit_field($in);
+$expected = 'a';
+is($got,$expected,$test_name);
+
Follow ups