aboutsummaryrefslogtreecommitdiffstats
path: root/t/config.t
diff options
context:
space:
mode:
Diffstat (limited to 't/config.t')
-rw-r--r--t/config.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/config.t b/t/config.t
new file mode 100644
index 0000000..4ecb8a7
--- /dev/null
+++ b/t/config.t
@@ -0,0 +1,40 @@
+use Test::More;
+use Iurt::Config;
+
+my %config_usage = (
+ option_with_false_default => {
+ default => 0
+ },
+ option_with_true_default => {
+ default => 1
+ },
+);
+my $config = {
+ option_with_false_default => 1,
+ option_with_true_default => 0,
+};
+my %run;
+
+config_init(\%config_usage, $config, \%run);
+is($config->{option_with_false_default}, 1, 'false default and true in config file');
+is($config->{option_with_true_default}, 0, 'true default and false in config file');
+
+$config = {};
+$run{config}{option_with_false_default} = 1;
+$run{config}{option_with_true_default} = 0;
+
+config_init(\%config_usage, $config, \%run);
+is($config->{option_with_false_default}, 1, 'false default and true on cmdline');
+is($config->{option_with_true_default}, 0, 'true default and false on cmdline');
+
+$config = {
+ option_with_false_default => 1,
+ option_with_true_default => 0,
+};
+$run{config}{option_with_false_default} = 0;
+$run{config}{option_with_true_default} = 1;
+config_init(\%config_usage, $config, \%run);
+is($config->{option_with_false_default}, 0, 'false default, true in config file, false on cmdline');
+is($config->{option_with_true_default}, 1, 'true default, false in config file, true on cmdline');
+
+done_testing();