diff options
Diffstat (limited to 'test/simplestore.t')
-rwxr-xr-x | test/simplestore.t | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/simplestore.t b/test/simplestore.t new file mode 100755 index 0000000..bbeea0d --- /dev/null +++ b/test/simplestore.t @@ -0,0 +1,25 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 7; +my $testfile = "/tmp/envstore-test-$$"; + +my $hash; + +BEGIN {use_ok('Simplestore')} +require_ok('Simplestore'); + +$hash = {foo => "bar\nbar"}; +ok(save($testfile, $hash), 'save hash 1'); +undef $hash; + +ok($hash = load($testfile), 'load hash 1'); +is($hash->{foo}, "bar\nbar", 'successful storage & load'); + +$hash = {dude => "dudette\nfoo"}; +$hash = load($testfile, $hash); +is($hash->{dude}, "dudette\nfoo", 'load: preserve hash keys'); + +$hash = {foo => "moose\nbaz"}; +$hash = load($testfile, $hash); +is($hash->{foo}, "bar\nbar", 'load: overwrite conflicting hash keys'); |