File: 1.simple.t

package info (click to toggle)
libgraph-writer-graphviz-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 128 kB
  • sloc: perl: 136; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 983 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
#!/usr/bin/env perl -w

use strict;
use Test::Simple tests => 2;
use IO::All;
use Graph;
use Graph::Writer::GraphViz;

sub normalized {
    my $s = shift;
    $s =~ s/\d+/0/g;
    $s =~ s/\s+/ /g;
    return $s;
}

my @v = qw/Alice Bob Crude Dr/;
my $g = Graph->new;
$g->add_vertices(@v);

my $wr = Graph::Writer::GraphViz->new(-format => 'dot');
$wr->write_graph($g,'t/graph.simple.dot');

ok(-f 't/graph.simple.dot');

$/ = undef;
my $g1 = <DATA>;
my $g2 = io('t/graph.simple.dot')->slurp;

$g1 = normalized($g1);
$g2 = normalized($g2);

ok($g1 eq $g2);
unlink('t/graph.simple.dot');

__DATA__
digraph test {
	graph [bb="0,0,285.9,36",
		ratio=fill
	];
	node [color=black,
		label="\N"
	];
	edge [color=black];
	Alice	[height=0.5,
		label=Alice,
		pos="29.897,18",
		width=0.83048];
	Bob	[height=0.5,
		label=Bob,
		pos="104.9,18",
		width=0.75];
	Crude	[height=0.5,
		label=Crude,
		pos="181.9,18",
		width=0.9027];
	Dr	[height=0.5,
		label=Dr,
		pos="258.9,18",
		width=0.75];
}