File: 04attribute.t

package info (click to toggle)
libgraph-perl 0.20102-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 184 kB
  • ctags: 132
  • sloc: perl: 1,455; makefile: 38
file content (92 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use Graph;

use strict;
local $^W = 1;

print "1..19\n";

my $g = Graph->new;

$g->add_edge('a', 'b');
$g->add_edge('b', 'c');
$g->add_edge('b', 'd');
$g->add_edge('a', 'e');

print "not " if $g->has_attribute;
print "ok 1\n";

print "not " if $g->has_attribute('a');
print "ok 2\n";

print "not " if $g->has_attribute('x');
print "ok 3\n";

print "not " if $g->has_attribute('a', 'b');
print "ok 4\n";

print "not " if $g->has_attribute('a', 'x');
print "ok 5\n";

print "not " if $g->has_attribute('x', 'a');
print "ok 6\n";

print "not " if $g->has_attribute('x', 'y');
print "ok 7\n";

$g->set_attribute('foo', 'bar');

print "not " unless $g->has_attribute('foo');
print "ok 8\n";

print "not " unless $g->get_attribute('foo') eq 'bar';
print "ok 9\n";

$g->set_attribute('foo', 'a', 'zog');

print "not " unless $g->has_attribute('foo', 'a');
print "ok 10\n";

print "not " unless $g->get_attribute('foo', 'a') eq 'zog';
print "ok 11\n";

$g->set_attribute('foo', 'a', 'b', 'zap');

print "not " unless $g->has_attribute('foo', 'a', 'b');
print "ok 12\n";

print "not " unless $g->get_attribute('foo', 'a', 'b') eq 'zap';
print "ok 13\n";

$g->set_attribute('goo', 'a', 'zik');

print "not " unless $g->has_attribute('goo', 'a');
print "ok 14\n";

print "not " unless $g->get_attribute('goo', 'a') eq 'zik';
print "ok 15\n";

my %a = $g->get_attributes('a');

print "not "
    unless scalar keys %a == 2 and $a{foo} eq 'zog' and $a{goo} eq 'zik';
print "ok 16\n";

$g->delete_attribute('foo', 'a');

%a = $g->get_attributes('a');

print "not "
    unless scalar keys %a == 1 and $a{goo} eq 'zik';
print "ok 17\n";

print "not " if $g->get_attribute('foo', 'a');
print "ok 18\n";

$g->delete_attributes('a');

%a = $g->get_attributes('a');

print "not "
    unless scalar keys %a == 0;
print "ok 19\n";