Add some tests for joinCSV and splitCSV in WebGUI::Text.
This commit is contained in:
parent
224773681b
commit
29ee8a00c7
1 changed files with 37 additions and 0 deletions
37
t/Text.t
Normal file
37
t/Text.t
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Text;
|
||||
use Test::More;
|
||||
|
||||
my @tests =
|
||||
(['basic', ['a', 'b', 'c'], 'a,b,c'],
|
||||
['inside null', ['a', '', 'c'], 'a,,c'],
|
||||
['end null', ['a', 'b', ''], 'a,b,'],
|
||||
['start null', ['', 'b', 'c'], ',b,c'],
|
||||
['all null', ['', '', ''], ',,'],
|
||||
['single null', [''], ''],
|
||||
['escape commas', ['w,x', 'y,z'], '"w,x","y,z"'],
|
||||
['escape double quotes', ['abc"def', 'ghi-jkl', 'mnop'], '"abc""def",ghi-jkl,mnop']);
|
||||
plan(tests => scalar(@tests) * 2);
|
||||
|
||||
foreach my $testspec (@tests) {
|
||||
my ($name, $record, $string) = @$testspec;
|
||||
is(WebGUI::Text::joinCSV(@$record), $string, "joinCSV $name");
|
||||
is_deeply($record, [WebGUI::Text::splitCSV($string)], "splitCSV $name");
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# mode: cperl
|
||||
# End:
|
||||
Loading…
Add table
Add a link
Reference in a new issue