| Thread Previous • Date Previous • Date Next • Thread Next |
Merge authors: Dan MacNeil (omacneil) phyxius (yashwanthgidugu) Related merge proposals: https://code.launchpad.net/~omacneil/mvhub/add_procedural_unit_tests/+merge/27096 proposed by: Dan MacNeil (omacneil) review: Approve - Lee Goodrich (leegoodrich) ------------------------------------------------------------ revno: 402 [merge] committer: Dan MacNeil <dan@xxxxxxxxxx> branch nick: trunk timestamp: Wed 2010-06-09 14:57:37 -0400 message: merged omacneil/mvhub/add_procedural_unit_tests added: lib-mvhub/t/Utils/undelimit_field.t modified: lib-mvhub/lib/MVHub/Common.pm lib-mvhub/lib/MVHub/Utils.pm -- lp:mvhub https://code.launchpad.net/~mvhub-commit/mvhub/trunk Your team MVHub Developers is subscribed to branch lp:mvhub. To unsubscribe from this branch go to https://code.launchpad.net/~mvhub-commit/mvhub/trunk/+edit-subscription
=== 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-05-08 17:04:15 +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:25:35 +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:28:13 +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);
+
| Thread Previous • Date Previous • Date Next • Thread Next |