File: colors.t

package info (click to toggle)
libconfig-simple-perl 4.59-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 659; makefile: 8
file content (62 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl -w
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl 1.t'

#########################

use strict;
use Test;
use Data::Dumper;
use FindBin '$RealBin';
use File::Spec;
BEGIN {
  plan tests => 30;
}

use Config::Simple;
ok(1);
#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

my $ini_file = File::Spec->catfile($RealBin, 'colors.ini');

my $cfg = new Config::Simple();
ok($cfg);
ok($cfg->read($ini_file));
ok($cfg->param('colors.average (2009)') eq 'blue');
ok($cfg->param('colors.average (2009') eq 'blue');
ok($cfg->param('colors.average (2009)a') eq 'blue');
ok($cfg->param('colors.average (2010)') eq 'blue');
ok($cfg->param('colors.average (2010') eq 'blue');
ok($cfg->param('colors.average (2010)a') eq 'blue');
ok($cfg->block() == 1);
my $vars = $cfg->vars();
ok($vars->{'colors.average (2009)'} eq 'blue');
ok($vars->{'colors.average (2009'} eq 'blue');
ok($vars->{'colors.average (2009)a'} eq 'blue');
ok($vars->{'colors.average (2010)'} eq 'blue');
ok($vars->{'colors.average (2010'} eq 'blue');
ok($vars->{'colors.average (2010)a'} eq 'blue');
ok($cfg->param(-name=>'colors.average (2009)', -value =>'blue'));
ok($cfg->param(-name=>'colors.average (2009', -value =>'blue'));
ok($cfg->param(-name=>'colors.average (2009)a', -value =>'blue'));
ok($cfg->param(-name=>'colors.average (2010)', -value =>'blue'));
ok($cfg->param(-name=>'colors.average (2010', -value =>'blue'));
ok($cfg->param(-name=>'colors.average (2010)a', -value =>'blue'));

# testing get_block():
ok( ref($cfg->param(-block=>'colors')) eq 'HASH' );
ok( $cfg->param(-block=>'colors')->{'average (2009)'} eq 'blue');
ok( $cfg->param(-block=>'colors')->{'average (2009'} eq 'blue');
ok( $cfg->param(-block=>'colors')->{'average (2009)a'} eq 'blue');
ok( $cfg->param(-block=>'colors')->{'average (2010)'} eq 'blue');
ok( $cfg->param(-block=>'colors')->{'average (2010'} eq 'blue');
ok( $cfg->param(-block=>'colors')->{'average (2010)a'} eq 'blue');

# now testing the new syntax:
my $data = Config::Simple->parse_ini_file($ini_file);
ok(ref($data) eq 'HASH');