Skip to content

Commit

Permalink
tidy up test code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Aug 14, 2007
1 parent a272600 commit c849b5f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
3 changes: 1 addition & 2 deletions t/pod.t
Expand Up @@ -3,6 +3,5 @@ use strict;

use Test::More;
eval "use Test::Pod 1.14";
plan skip_all => "Test::Pod 1.14 required for testing POD"
if $@;
plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
all_pod_files_ok();
72 changes: 36 additions & 36 deletions t/reader.t
Expand Up @@ -15,35 +15,35 @@ isa_ok($hashref, 'HASH', "return of Config::INI::Reader->read_file");

# Check the structure of the config
my $expected = {
'_' => {
root => 'something',
},
section => {
one => 'two',
Foo => 'Bar',
this => 'Your Mother!',
blank => '',
moo => 'kooh',
},
'Section Two' => {
'something else' => 'blah',
'remove' => 'whitespace',
},
};
'_' => {
root => 'something',
},
section => {
one => 'two',
Foo => 'Bar',
this => 'Your Mother!',
blank => '',
moo => 'kooh',
},
'Section Two' => {
'something else' => 'blah',
'remove' => 'whitespace',
},
};

is_deeply($hashref, $expected, 'Config structure matches expected');

# Add some stuff to the trivial config and check write_string() for it
my $Trivial = {};
$Trivial->{_} = { root1 => 'root2' };
$Trivial->{section} = {
foo => 'bar',
this => 'that',
blank => '',
};
foo => 'bar',
this => 'that',
blank => '',
};
$Trivial->{section2} = {
'this little piggy' => 'went to market'
};
'this little piggy' => 'went to market'
};

my $string = <<END;
root1=root2
Expand All @@ -58,30 +58,30 @@ this little piggy=went to market
END

{ # Test read_string
my $hashref = Config::INI::Reader->read_string( $string );
isa_ok($hashref, 'HASH', "return of Config::INI::Reader->read_string");
my $hashref = Config::INI::Reader->read_string( $string );
isa_ok($hashref, 'HASH', "return of Config::INI::Reader->read_string");

is_deeply( $hashref, $Trivial, '->read_string returns expected value' );
is_deeply( $hashref, $Trivial, '->read_string returns expected value' );
}

{ # Test read_handle
my $fh = IO::File->new('examples/simple.ini', 'r');
my $data = do { local $/ = undef; <$fh> };

is_deeply(
Config::INI::Reader->new->read_handle( IO::String->new($data) ),
$expected,
'->read_handle returns expected value'
);
my $fh = IO::File->new('examples/simple.ini', 'r');
my $data = do { local $/ = undef; <$fh> };

is_deeply(
Config::INI::Reader->new->read_handle( IO::String->new($data) ),
$expected,
'->read_handle returns expected value'
);
}

#####################################################################
# Bugs that happened we don't want to happen again

{
# Reading in an empty file, or a defined but zero length string, should yield
# a valid, but empty, object.
my $empty = Config::INI::Reader->read_string('');
is_deeply($empty, {}, "an empty string gets an empty hashref");
# Reading in an empty file, or a defined but zero length string, should yield
# a valid, but empty, object.
my $empty = Config::INI::Reader->read_string('');
is_deeply($empty, {}, "an empty string gets an empty hashref");
}

0 comments on commit c849b5f

Please sign in to comment.