Skip to content

Commit

Permalink
Item9970: Trying to add some unit tests to catch formfield 0 problems…
Browse files Browse the repository at this point in the history
… in future

This one actually does not catch the problem with 9970 but it is still a nice test to have


git-svn-id: http://svn.foswiki.org/branches/Release01x01@9892 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Nov 7, 2010
1 parent 73d07f6 commit b094959
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions UnitTestContrib/test/unit/MetaTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ sub test_multiple {
$this->assert_str_equals( $vals2->{"value"}, "3" );
}

# Field with value 0 and value '' This does not cover Item8738
sub test_zero_empty {
my $this = shift;
my $meta = Foswiki::Meta->new( $this->{session}, $web, $topic );

my $args_zero = {
name => "a",
value => "0"
};

my $args_empty = {
name => "b",
value => ""
};

$meta->putKeyed( "FIELD", $args_zero );
$meta->putKeyed( "FIELD", $args_empty );

my $vals1 = $meta->get( "FIELD", "a" );
$this->assert_str_equals( $vals1->{"name"}, "a" );
$this->assert_str_equals( $vals1->{"value"}, "0" );

my $vals2 = $meta->get( "FIELD", "b" );
$this->assert_str_equals( $vals2->{"name"}, "b" );
$this->assert_str_equals( $vals2->{"value"}, "" );
}

sub test_removeSingle {
my $this = shift;
my $meta = Foswiki::Meta->new( $this->{session}, $web, $topic );
Expand Down

0 comments on commit b094959

Please sign in to comment.