| 1 |
use warnings; |
| 2 |
|
| 3 |
# Before `make install' is performed this script should be runnable with |
| 4 |
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t' |
| 5 |
|
| 6 |
######################### |
| 7 |
|
| 8 |
# change 'tests => 1' to 'tests => last_test_to_print'; |
| 9 |
|
| 10 |
use strict; |
| 11 |
use Test::More; |
| 12 |
BEGIN { use_ok('Lemonldap::NG::Common::Conf') } |
| 13 |
|
| 14 |
######################### |
| 15 |
|
| 16 |
# Insert your test code below, the Test::More module is use()ed here so read |
| 17 |
# its man page ( perldoc Test::More ) for help writing this test script. |
| 18 |
|
| 19 |
my $confAcc; |
| 20 |
use File::Temp; |
| 21 |
my $dir = File::Temp::tempdir( CLEANUP => 1 ); |
| 22 |
|
| 23 |
ok( |
| 24 |
$confAcc = new Lemonldap::NG::Common::Conf( { |
| 25 |
type => 'File', |
| 26 |
dirName => $dir, |
| 27 |
} |
| 28 |
), |
| 29 |
'type => file', |
| 30 |
); |
| 31 |
my $count = 2; |
| 32 |
|
| 33 |
my @test = ( |
| 34 |
|
| 35 |
# simple ascii |
| 36 |
{ cfgNum => 1, test => 'ascii' }, |
| 37 |
|
| 38 |
# utf-8 |
| 39 |
{ cfgNum => 1, test => 'Русский' }, |
| 40 |
|
| 41 |
# compatible utf8/latin-1 char but with different codes |
| 42 |
{ cfgNum => 1, test => 'éà' } |
| 43 |
); |
| 44 |
|
| 45 |
for ( my $i = 0 ; $i < @test ; $i++ ) { |
| 46 |
ok( $confAcc->store( $test[$i] ) == 1, "Test $i is stored" ) |
| 47 |
or print STDERR "$Lemonldap::NG::Common::Conf::msg $!"; |
| 48 |
$count++; |
| 49 |
my $cfg; |
| 50 |
ok( $cfg = $confAcc->load(1), "Test $i can be read" ) |
| 51 |
or print STDERR $Lemonldap::NG::Common::Conf::msg; |
| 52 |
ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" ) |
| 53 |
or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n"; |
| 54 |
$count += 2; |
| 55 |
} |
| 56 |
|
| 57 |
done_testing($count); |