line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# Copyright (C) 2010 NZ Registry Services |
3
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
package Test::XML::Assert; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
23338
|
use 5.006000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
9
|
|
|
|
|
|
|
#use base 'Test::Builder::Module'; |
10
|
1
|
|
|
1
|
|
6
|
use Test::Builder::Module; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Test::Builder::Module); |
12
|
1
|
|
|
1
|
|
598
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use XML::Assert; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( |
16
|
|
|
|
|
|
|
is_xpath_count |
17
|
|
|
|
|
|
|
does_xpath_value_match |
18
|
|
|
|
|
|
|
do_xpath_values_match |
19
|
|
|
|
|
|
|
does_attr_value_match |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
25
|
|
|
|
|
|
|
my $PARSER = XML::LibXML->new(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub is_xpath_count($$$$;$) { |
28
|
|
|
|
|
|
|
my ($doc, $xmlns, $xpath, $count, $name) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# create the $xml_assert object |
31
|
|
|
|
|
|
|
my $xml_assert = XML::Assert->new(); |
32
|
|
|
|
|
|
|
$xml_assert->xmlns($xmlns); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# do the test and remember the result |
35
|
|
|
|
|
|
|
my $is_ok = $xml_assert->is_xpath_count($doc, $xpath, $count); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
38
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub does_xpath_value_match($$$$;$) { |
42
|
|
|
|
|
|
|
my ($doc, $xmlns, $xpath, $match, $name) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $xml_assert = XML::Assert->new(); |
45
|
|
|
|
|
|
|
$xml_assert->xmlns($xmlns); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# do the test and remember the result |
48
|
|
|
|
|
|
|
my $is_ok = $xml_assert->does_xpath_value_match($doc, $xpath, $match); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
51
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub do_xpath_values_match($$$$;$) { |
55
|
|
|
|
|
|
|
my ($doc, $xmlns, $xpath, $match, $name) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $xml_assert = XML::Assert->new(); |
58
|
|
|
|
|
|
|
$xml_assert->xmlns($xmlns); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# do the test and remember the result |
61
|
|
|
|
|
|
|
my $is_ok = $xml_assert->do_xpath_values_match($doc, $xpath, $match); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
64
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub does_attr_value_match($$$$$;$) { |
68
|
|
|
|
|
|
|
my ($doc, $xmlns, $xpath, $attr, $match, $name) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $xml_assert = XML::Assert->new(); |
71
|
|
|
|
|
|
|
$xml_assert->xmlns($xmlns); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# do the test and remember the result |
74
|
|
|
|
|
|
|
my $is_ok = $xml_assert->does_attr_value_match($doc, $xpath, $attr, $match); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
77
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub do_attr_values_match($$$$;$) { |
81
|
|
|
|
|
|
|
my ($doc, $xmlns, $xpath, $attr, $match, $name) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $xml_assert = XML::Assert->new(); |
84
|
|
|
|
|
|
|
$xml_assert->xmlns($xmlns); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# do the test and remember the result |
87
|
|
|
|
|
|
|
my $is_ok = $xml_assert->do_attr_values_match($doc, $xpath, $attr, $match); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
90
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |