File: parse_line.t

package info (click to toggle)
libconfigreader-simple-perl 1.28-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 212 kB
  • ctags: 27
  • sloc: perl: 696; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use strict;
use warnings;

use Test::More 'no_plan';

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my $class  = 'ConfigReader::Simple';
my $method = 'parse_line';

use_ok( $class );

ok( defined &ConfigReader::Simple::parse_line, "$method is defined" );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Try it with a line that should work
{
my( $directive, $value ) = &ConfigReader::Simple::parse_line(
	"Cat = Buster" );
is( $directive, 'Cat'    );
is( $value,     'Buster' );
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Try it with a line that should fails
{
my $rc = eval { &ConfigReader::Simple::parse_line( "" ) };
my $at = $@;
ok( length $at, "eval of parse_line failed with empty string" );
like( $at, qr/Can't parse/, "Reports that it can't parse the string" );
}