File: as_vcg.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 (54 lines) | stat: -rw-r--r-- 1,181 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
#!/usr/bin/perl -w

# Some basic as_vcg tests

use Test::More;
use strict;

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

can_ok ('Graph::Easy', qw/
  as_vcg
  as_vcg_file
  /);

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

my $vcg = $graph->as_vcg();
my $vcg_file = $graph->as_vcg_file();

# remove time stamp:
$vcg =~ s/ at.*//;
$vcg_file =~ s/ at.*//;
is ($vcg, $vcg_file, 'as_vcg and as_vcg_file are equal');

$graph->add_edge('A','B');

like ($graph->as_vcg(), qr/edge: \{ sourcename: "A" targetname: "B" \}/,
	'as_vcg matches');

# set edge label
my @edges = $graph->edges();
$edges[0]->set_attribute('label', 'my car');

like ($graph->as_vcg(),
	qr/edge: \{ label: "my car" sourcename: "A" targetname: "B" \}/,
	'as_vcg matches');

#############################################################################
# graph label

$graph = Graph::Easy->new();
$graph->set_attribute('label', 'my graph label');

like ($graph->as_vcg(), qr/title: "my graph label"/,
	'as_vcg has graph label');