9
BEGIN { plan tests => 15 }
14
# Get files from the 't' directory, portably
15
chdir('t') if ( -d 't' );
18
# Load ini file and write as new file
19
$ini = new Config::IniFiles -file => "test.ini";
20
$ini->SetFileName("test03.ini");
21
$ini->SetWriteMode("0666");
28
# Section comments preserved
30
if( open FILE, "<test03.ini" ) {
31
$_ = join( '', <FILE> );
32
$value = /\# This is a section comment[$ors]\[test1\]/;
39
# Parameter comments preserved
40
$value = /\# This is a parm comment[$ors]five=value5/;
45
# Setting Section Comment
46
$ini->setval('foo','bar','qux');
47
ok($ini->SetSectionComment('foo', 'This is a section comment', 'This comment takes two lines!'));
50
# Getting Section Comment
51
my @comment = $ini->GetSectionComment('foo');
52
ok( join('', @comment) eq '# This is a section comment# This comment takes two lines!');
55
# Deleting Section Comment
56
$ini->DeleteSectionComment('foo');
58
ok(not defined $ini->GetSectionComment('foo'));
61
# Setting Parameter Comment
62
ok($ini->SetParameterComment('foo', 'bar', 'This is a parameter comment', 'This comment takes two lines!'));
65
# Getting Parameter Comment
66
@comment = $ini->GetParameterComment('foo', 'bar');
67
ok(join('', @comment) eq '# This is a parameter comment# This comment takes two lines!');
70
# Deleting Parameter Comment
71
$ini->DeleteParameterComment('foo', 'bar');
73
ok(not defined $ini->GetSectionComment('foo', 'bar'));
77
# Reading a section comment from the file
78
@comment = $ini->GetSectionComment('test1');
79
ok(join('', @comment) eq '# This is a section comment');
82
# Reading a parameter comment from the file
83
@comment = $ini->GetParameterComment('test2', 'five');
84
ok(join('', @comment) eq '# This is a parm comment');
87
# Reading a comment that starts with ';'
88
@comment = $ini->GetSectionComment('MixedCaseSect');
89
ok(join('', @comment) eq '; This is a semi-colon comment');
93
# Loading from a file with alternate comment characters
94
# and also test continuation characters (in one file)
95
$ini = Config::IniFiles->new(
103
$value = $ini->GetParameterComment('Library', 'addmultf_lib');
104
ok ($value =~ /\@#\@CF Automatically created by 'config_project' at Thu Mar 21 08:46:54 2002/);
107
$value = $ini->val('turbo_library', 'TurboLibPaths');
108
ok ($value =~ m:\$WORKAREA/resources/c11_test_flow/vhdl_rtl\s+\$WORKAREA/resources/cstarlib_reg_1v5/vhdl_rtl:);
110
# Clean up when we're done