File: 05.zero.t

package info (click to toggle)
libconfig-tiny-perl 2.30-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 208 kB
  • sloc: perl: 394; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 979 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
#!/usr/bin/perl

use Config::Tiny;

use File::Spec;
use File::Temp;

use Test::More tests => 6;

use utf8;

# ------------------------

my($conf0) = Config::Tiny -> read('t/0');

ok($$conf0{init}{a} eq 'b', 'Hashref after read() returns correct value');

# The EXLOCK option is for BSD-based systems.

my($temp_dir)  = File::Temp -> newdir('temp.XXXX', CLEANUP => 1, EXLOCK => 0, TMPDIR => 1);
my($temp_file) = File::Spec -> catfile($temp_dir, '0');
my($string)    =<<EOS;
[init]
a = b
EOS
my($conf1) = Config::Tiny -> read_string($string);

ok($conf1, 'read_string() returns true');

is_deeply($conf1, {init => {a => 'b'} }, 'read_string() returns expected value');

$conf1 -> write($temp_file);

my($conf2) = Config::Tiny -> read($temp_file);

is_deeply($conf1, $conf1, 'write() followed by read() works');
is_deeply($conf2, {init => {a => 'b'} }, 'write() + read() returns expected value');
is_deeply($conf0, {init => {a => 'b'} }, 'write() + read() returns expected value');