From 811cfdedc2bb26745ec3eb84ec07d4026b037060 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Sun, 31 May 2009 02:27:21 +0300 Subject: a test-case for fixes of latest commits --- t/array_hash.t | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 t/array_hash.t diff --git a/t/array_hash.t b/t/array_hash.t new file mode 100755 index 0000000..01f1e02 --- /dev/null +++ b/t/array_hash.t @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use strict; +use Test; +use Data::Dumper; + +use lib '../lib'; + +BEGIN { plan tests => 8 } +use Asterisk::config; + +my $file = "t/array_hash.conf"; +open TRUNCATED_FILE, ">$file"; +close TRUNCATED_FILE; + +my $conf = new Asterisk::config(file => $file); + +$conf->assign_addsection(section=>"test-array"); +$conf->assign_append(section=>"test-array", point=>"foot", + data=> [ + "a = b", + "var = value", + ]); +$conf->assign_addsection(section=>"test-hash"); +$conf->assign_append(section=>"test-hash", point=>"foot", + data=> { + a => "b", + var => "value", + }); + +#$conf->assign_addsection(section=>"[unsection]"); +$conf->assign_append(point=>"up", + data=> [ + "a = b", + "var = value", + ]); +#$conf->assign_addsection(section=>"[unsection]"); +$conf->assign_append(point=>"up", + data=> { + a1 => "b", + var1 => "value", + }); + + + +$conf->save_file(); +$conf->reload(); + +ok(@{$conf->fetch_values_arrayref(section=>'test-array', key=>'a' )}[0] eq 'b' ); +ok(@{$conf->fetch_values_arrayref(section=>'test-array', key=>'var')}[0] eq 'value'); +ok(@{$conf->fetch_values_arrayref(section=>'test-hash', key=>'a' )}[0] eq 'b' ); +ok(@{$conf->fetch_values_arrayref(section=>'test-array', key=>'var')}[0] eq 'value'); +ok(@{$conf->fetch_values_arrayref(section=>'[unsection]',key=>'a' )}[0] eq 'b' ); +ok(@{$conf->fetch_values_arrayref(section=>'[unsection]',key=>'var' )}[0] eq 'value'); +ok(@{$conf->fetch_values_arrayref(section=>'[unsection]',key=>'a1' )}[0] eq 'b' ); +ok(@{$conf->fetch_values_arrayref(section=>'[unsection]',key=>'var1')}[0] eq 'value'); -- cgit v1.2.3