/[pub]/suikawiki/script/t/db-fs-base.t
Suika

Contents of /suikawiki/script/t/db-fs-base.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Fri Apr 2 04:29:46 2004 UTC (20 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
File MIME type: application/x-troff
New tests

1 #!/usr/bin/perl -w
2 use strict;
3 use Test;
4 use SuikaWiki::DB::FileSystem::Base;
5 use File::Spec;
6
7 my $db = new SuikaWiki::DB::FileSystem::Base
8 base_directory => q<base>,
9 root_file => q<root>,
10 directory_prefix => 'dir--',
11 directory_suffix => '.ns',
12 file_prefix => 'file--',
13 file_suffix => '.name';
14
15 my $db2 = new SuikaWiki::DB::FileSystem::Base
16 base_directory => q<base>,
17 root_key => [qw/ROOT/],
18 directory_prefix => 'dir--',
19 directory_suffix => '.ns',
20 file_prefix => 'file--',
21 file_suffix => '.name';
22
23 plan tests => 16;
24
25 ok $db->__keyns2dirname (keyns => "\x31\x32\x33"), 'dir--313233.ns';
26 ok $db->__keyname2filename (keyname => "\x31\x32\x33"), 'file--313233.name';
27
28 ok $db->__key2filepath (key => [qw/123/]),
29 File::Spec->catfile (qw/base file--313233.name/);
30 ok $db->__key2filepath (key => [qw/123 456/]),
31 File::Spec->catfile (qw/base dir--313233.ns file--343536.name/);
32 ok $db->__key2filepath (key => [qw/123 456 789/]),
33 File::Spec->catfile (qw/base dir--313233.ns dir--343536.ns file--373839.name/);
34
35 ok $db->__key2filepath (key => []),
36 File::Spec->rel2abs ('root', 'base');
37
38 ok $db2->__key2filepath (key => []),
39 File::Spec->catfile (qw/base file--524F4F54.name/);
40
41 ok $db->__key2dirpath (key => []),
42 File::Spec->catdir (qw/base /);
43 ok $db->__key2dirpath (key => [qw/123/]),
44 File::Spec->catdir (qw/base dir--313233.ns/);
45 ok $db->__key2dirpath (key => [qw/123 456/]),
46 File::Spec->catdir (qw/base dir--313233.ns dir--343536.ns/);
47 ok $db->__key2dirpath (key => [qw/123 456 789/]),
48 File::Spec->catdir (qw/base dir--313233.ns dir--343536.ns dir--373839.ns/);
49
50 ok $db->__key2dirpath (fullkey => [qw/123/]),
51 File::Spec->catdir (qw/base/);
52 ok $db->__key2dirpath (fullkey => [qw/123 456/]),
53 File::Spec->catdir (qw/base dir--313233.ns/);
54 ok $db->__key2dirpath (fullkey => [qw/123 456 789/]),
55 File::Spec->catdir (qw/base dir--313233.ns dir--343536.ns/);
56
57
58 ok $db->__dirname2keyns (dirname => 'dir--313233.ns'), "123";
59 ok $db->__filename2keyname (filename => 'file--313233.name'), "123";
60
61

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24