File: cell.t

package info (click to toggle)
libgraph-easy-perl 0.76-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,264 kB
  • sloc: perl: 23,869; makefile: 7
file content (120 lines) | stat: -rw-r--r-- 2,679 bytes parent folder | download | duplicates (5)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl -w

# Test Graph::Easy::Node::Cell

use Test::More;
use strict;

BEGIN
   {
   plan tests => 28;
   chdir 't' if -d 't';
   use lib '../lib';
   use_ok ("Graph::Easy::Node::Cell") or die($@);
   use_ok ("Graph::Easy") or die($@);
   use_ok ("Graph::Easy::As_ascii") or die($@);
   };

can_ok ("Graph::Easy::Node::Cell", qw/
  new
  as_ascii as_html
  error
  class
  name
  successors
  predecessors
  width
  height
  pos
  x
  y
  class
  title
  del_attribute
  set_attribute
  set_attributes
  attribute
  group add_to_group
  /);

#############################################################################

my $cell = Graph::Easy::Node::Cell->new();

is (ref($cell), 'Graph::Easy::Node::Cell');

is ($cell->error(), '', 'no error yet');

is ($cell->x(), 0, 'x == 0');
is ($cell->y(), 0, 'x == 0');
is ($cell->label(), '', 'label');
is ($cell->name(), '', 'name');
is ($cell->title(), '', 'no title per default');
is (join(",", $cell->pos()), "0,0", 'pos = 0,0');
is ($cell->width(),  undef, 'w == undef');
is ($cell->height(), undef, 'h == undef');

is ($cell->class(), '', 'no class');

#############################################################################
# as_ascii/as_html

is ($cell->as_ascii(), '', 'as_ascii');
is ($cell->as_html(), '', 'as_html');

$cell->_correct_size();

is ($cell->width(),  0, 'w = 0');
is ($cell->height(), 0, 'h = 0');

#############################################################################
# group tests

use Graph::Easy::Group;

my $group = Graph::Easy::Group->new( { name => 'foo' } );

# fake that the cell belongs as filler to a node
my $node = Graph::Easy::Node->new( 'foo' );
$cell->{node} = $node;

is ($cell->node(), $node, 'node for cell');
is ($cell->group(), undef, 'no group yet');

$node->add_to_group($group);

is ($cell->node(), $node, 'node for cell');
is ($cell->group(), $group, 'group foo');

#############################################################################
# title tests

$cell->set_attribute('title', "foo title");

is ($cell->title(), 'foo title', 'foo title');

$cell->del_attribute('title');
$cell->set_attribute('autotitle', 'name');

is ($cell->title(), $cell->name(), 'title equals name');

#############################################################################
# invisible nodes

$node = Graph::Easy::Node->new( { name => "anon 0", label => 'X' } );
$node->set_attribute('shape', "invisible");

is ($node->as_ascii(), "", 'invisible text node');

#############################################################################
# as_txt()

use_ok ('Graph::Easy::As_txt');

can_ok ("Graph::Easy::Node::Cell", qw/
  attributes_as_txt
  as_txt
  as_pure_txt
  /);