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######################### We start with some black magic to print on failure.
5
6# Change 1..1 below to 1..last_test_to_print .
7# (It may become useful if the test is moved to ./t subdirectory.)
8
9use Test::More tests => 8;
10
11use XML::SimpleObject::LibXML;
12
13######################### End of black magic.
14
15# Insert your test code below (better if it prints "ok 13"
16# (correspondingly "not ok 13") depending on the success of chunk 13
17# of the test code):
18
19my $XML = <<END;
20  <files>
21    <file type="symlink">
22      <name>/etc/dosemu.conf</name>
23      <dest>dosemu.conf-drdos703.eval</dest>
24      <bytes>0</bytes>
25    </file>
26    <file>
27      <name>/etc/passwd</name>
28      <bytes>948</bytes>
29    </file>
30  </files>
31END
32
33my $parser = new XML::LibXML;
34ok($parser);
35my $xmlobj = new XML::SimpleObject::LibXML ($parser->parse_string($XML));
36ok($xmlobj);
37
38is(($xmlobj->child("files")->children("file"))[0]->child("name")->value,
39     "/etc/dosemu.conf");
40is(($xmlobj->child("files")->children("file"))[0]->attribute("type"),
41     "symlink");
42is(($xmlobj->child("files")->children("file"))[1]->child("name")->value,
43     "/etc/passwd");
44
45($xmlobj->child("files")->children("file"))[0]->child("name")->add_attribute
46     ("lang", "en");
47is(($xmlobj->child("files")->children("file"))[0]->child("name")->attribute("lang"),
48     "en");
49
50my $child = ($xmlobj->child("files")->children("file"))[0]->child("name")->add_child
51     ("tmp", "try");
52is($child->name,"tmp");
53is($child->value,"try");
54
55