File: output.t

package info (click to toggle)
libgraph-easy-as-svg-perl 0.28-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 1,924; makefile: 7
file content (94 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl

# test that the output doesn't contain things it shouldn't

use Test::More;
use strict;

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

#############################################################################
my $graph = Graph::Easy->new();

is (ref($graph), 'Graph::Easy');

my ($A,$B,$E) = $graph->add_edge('A','B','C');

my ($N) = $graph->add_anon_node();
$graph->add_edge('B',$N);

my ($G) = $graph->add_group('G');

# some attributes that should not be output:

$A->set_attribute('flow','east');
$A->set_attribute('autolabel','12');
$A->set_attribute('shape','diamond');
$A->set_attribute('group','G');
$A->set_attribute('format','pod');

$B->set_attribute('shape','point');
$B->set_attribute('point-shape','star');
$B->set_attribute('point-style','closed');
$B->set_attribute('border-style','double');
$B->set_attribute('offset','2,2');
$B->set_attribute('origin','A');
$B->set_attribute('textwrap','auto');

$graph->set_attribute('type','undirected');
$graph->set_attribute('node','columns','2');
$graph->set_attribute('labelpos','bottom');
$graph->set_attribute('root','A');

$E->set_attribute('labelcolor','green');
$E->set_attribute('autojoin','always');
$E->set_attribute('autosplit','always');
$E->set_attribute('end','north');
$E->set_attribute('start','east');
$E->set_attribute('minlen','2');
$E->set_attribute('fill','red');
$E->set_attribute('format','pod');
$E->set_attribute('textwrap','auto');

$G->set_attribute('root','A');

# some things that should be in the output
$A->set_attribute('id','A1');


# this will load As_svg:
my $svg = $graph->as_svg();

for my $w (qw/
	flow auto-label arrow-style arrow-shape
	shape point-shape
	auto-join auto-split
	end start minlen
	offset origin columns
	label-pos label-color format root rank
	textwrap format
	/)
   {
   unlike ($svg, qr/$w=/, "attribute $w skipped");
   if ($w =~ /-/)
     {
     my $w2 = $w; $w2 =~ s/-//g;
     unlike ($svg, qr/$w2=/, "attribute $w skipped");
     }
   }
like ($svg, qr/(id)="/, 'attribute id included');

unlike ($svg, qr/type=.undirected/, "attribute type for graph skipped");

#print $graph->as_txt();
# print STDERR $svg."\n";

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

# all tests done