Skip to content

Commit

Permalink
test the delete() method
Browse files Browse the repository at this point in the history
  • Loading branch information
book committed Nov 20, 2006
1 parent 54a3527 commit dc6c64a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions t/11property.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ owww
PROPS-END
END_OF_PROPERTY

plan tests => 14 + 2 * @tests;
plan tests => 20 + 2 * @tests;

# create a new empty property block
my $p = SVN::Dump::Property->new();
Expand Down Expand Up @@ -71,9 +71,22 @@ push @tests, [swish => 'ker_sploosh' ];
is_deeply( [ $p->keys() ], [ map { $_->[0] } @tests ], "Keys in order" );
is_deeply( [ $p->values() ], [ map { $_->[1] } @tests ], "Values in order" );

#
# delete the new key
is( $p->delete('swish'), 'ker_sploosh', 'delete() returns the value' );
is( $p->delete('swish'), undef, 'delete() non-existing key' );
is( $p->delete(), undef, 'delete() no key' );

# update the expected result
$as_string =~ s/kapow/urkkk/; # same length
$as_string =~ s/PROPS-END/K 5\012swish\012V 11\012ker_sploosh\012PROPS-END/;

is_same_string( $p->as_string(), $as_string, 'Property serialisation' );

# check that delete() behaves like the builtin delete()
$p->set(@$_) for ( [ foo => 11 ], [ bar => 22 ], [ baz => 33 ] );
my $scalar = $p->delete('foo');
is( $scalar, 11, '$scalar is 11 (perldoc -f delete)' );
$scalar = $p->delete(qw(foo bar));
is( $scalar, 22, '$scalar is 22 (perldoc -f delete)' );
my @array = $p->delete(qw(foo bar baz));
is_deeply( \@array, [ undef, undef, 33 ], '@array is (undef, undef,33)' );

0 comments on commit dc6c64a

Please sign in to comment.