File: node_get_set.t

package info (click to toggle)
libconfig-model-perl 2.155-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,172 kB
  • sloc: perl: 15,117; makefile: 19
file content (50 lines) | stat: -rw-r--r-- 1,135 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
# -*- cperl -*-

use ExtUtils::testlib;
use Test::More;
use Test::Memory::Cycle;
use Config::Model;
use Config::Model::Tester::Setup qw/init_test/;

use warnings;
use strict;

use lib "t/lib";

my ($model, $trace) = init_test();

ok( 1, "compiled" );

my $inst = $model->instance(
    root_class_name => 'Master',
    instance_name   => 'test1'
);
ok( $inst, "created dummy instance" );

my $root = $inst->config_root;

# check with embedded \n
my $step = qq!std_id:ab X=Bv - std_id:bc X=Av - a_string="titi and toto" !;
ok( $root->load( step => $step ), "load '$step'" );

foreach ( [ "/std_id/cc/X", "Bv" ], ) {
    my ( $path, $exp ) = @$_;
    is( $root->set( $path, $exp ), 1, "Test set $path" );
}

foreach ( [ "/std_id/bc/X", "Av" ], [ "/std_id/cc/X", "Bv" ], ) {
    my ( $path, $exp ) = @$_;
    is( $root->get($path), $exp, "Test get $path" );
}

is(
    $root->get( path => "/std_id/bc/X", get_obj => 1 ),
    $root->grab("std_id:bc X"),
    "test get with get_obj"
);

is( $root->get( path => '/BDMV', check => 'skip' ), undef, "get with check skip does not die" );

memory_cycle_ok($model, "memory cycle");

done_testing;