summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2009-05-31 02:27:21 +0300
committerTzafrir Cohen <tzafrir@cohens.org.il>2009-05-31 02:27:21 +0300
commit811cfdedc2bb26745ec3eb84ec07d4026b037060 (patch)
treed6b42eef1a964de1263bdcd96b716c6a7a7bc6c2
parent9e399fad788f48708591f55c0660f95ec8f43f5c (diff)
a test-case for fixes of latest commits
-rwxr-xr-xt/array_hash.t56
1 files changed, 56 insertions, 0 deletions
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');