~ubuntu-branches/ubuntu/warty/libconfig-auto-perl/warty

« back to all changes in this revision

Viewing changes to t/01_Config-Auto.t

  • Committer: Bazaar Package Importer
  • Author(s): Marc 'HE' Brockschmidt
  • Date: 2004-02-26 16:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040226160821-opxbtt3gb2bylksh
Tags: upstream-0.06
ImportĀ upstreamĀ versionĀ 0.06

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Before `make install' is performed this script should be runnable with
 
2
# `make test'. After `make install' it should work as `perl test.pl'
 
3
 
 
4
#########################
 
5
 
 
6
# change 'tests => 1' to 'tests => last_test_to_print';
 
7
 
 
8
use Test;
 
9
BEGIN { plan tests => 18 };
 
10
use Config::Auto;
 
11
ok(1); # If we made it this far, we're ok.
 
12
 
 
13
#########################
 
14
 
 
15
# Insert your test code below, the Test module is use()ed here so read
 
16
# its man page ( perldoc Test ) for help writing this test script.
 
17
 
 
18
sub t {
 
19
    open OUT, ">test.config" or die $!;
 
20
    print OUT @_;
 
21
    close OUT;
 
22
    my $c = Config::Auto::parse("test.config");
 
23
    unlink "test.config";
 
24
    return $c;
 
25
}
 
26
 
 
27
my $c;
 
28
$c = t(<<EOF);
 
29
search oucs.ox.ac.uk ox.ac.uk
 
30
nameserver 163.1.2.1
 
31
nameserver 129.67.1.1
 
32
nameserver 129.67.1.180
 
33
EOF
 
34
 
 
35
ok(ref ($c->{nameserver}) eq "ARRAY");
 
36
ok($c->{nameserver}[0] eq "163.1.2.1");
 
37
ok(ref ($c->{search}) eq "ARRAY");
 
38
 
 
39
$c = t(<<EOF);
 
40
root:x:0:0:root:/root:/bin/bash
 
41
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
 
42
bin:x:2:2:bin:/bin:/bin/sh
 
43
EOF
 
44
 
 
45
ok(ref($c->{root}) eq "ARRAY");
 
46
ok($c->{root}[0] eq "x");
 
47
 
 
48
$c = t(<<EOF);
 
49
# This file was generated by debconf automaticaly.
 
50
# Please use dpkg-reconfigure to edit.
 
51
# And you can copy this file to ~/.mozillarc to override.
 
52
MOZILLA_DSP=auto
 
53
USE_GDKXFT=false
 
54
EOF
 
55
 
 
56
ok($c->{MOZILLA_DSP} eq "auto");
 
57
 
 
58
$c = t(<<EOF);
 
59
# /etc/nsswitch.conf
 
60
#
 
61
# Example configuration of GNU Name Service Switch functionality.
 
62
# If you have the `glibc-doc' and `info' packages installed, try:
 
63
# `info libc "Name Service Switch"' for information about this file.
 
64
 
 
65
passwd:         compat
 
66
group:          compat
 
67
shadow:         compat
 
68
 
 
69
hosts:          files dns
 
70
EOF
 
71
 
 
72
ok($c->{passwd} eq "compat");
 
73
ok(ref $c->{hosts} eq "ARRAY");
 
74
 
 
75
$c = t(<<EOF);
 
76
test: foo=bar
 
77
test: baz
 
78
quux: zoop
 
79
 
 
80
EOF
 
81
 
 
82
ok($c->{quux} eq "zoop");
 
83
ok(ref $c->{test} eq "HASH");
 
84
ok($c->{test}{foo} eq "bar");
 
85
ok($c->{test}{baz} == 1);
 
86
 
 
87
$c = t(<<EOF);
 
88
[group1]
 
89
host = proxy.some-domain-name.com
 
90
port = 80
 
91
username = blah
 
92
password = doubleblah
 
93
EOF
 
94
 
 
95
ok(ref $c->{"group1"} eq "HASH");
 
96
ok($c->{"group1"}{"host"} eq "proxy.some-domain-name.com");
 
97
ok($c->{"group1"}{"port"} eq "80");
 
98
ok($c->{"group1"}{"username"} eq "blah");
 
99
ok($c->{"group1"}{"password"} eq "doubleblah");
 
100