File: boxart.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 (92 lines) | stat: -rw-r--r-- 2,400 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
#!/usr/bin/perl -w

use Test::More;
use strict;

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

can_ok ("Graph::Easy", qw/
  as_boxart
  as_boxart_html
  as_boxart_html_file
  as_boxart_file
  /);

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

binmode STDERR, ':utf8';
# some of our strings are written in utf8
use utf8;

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

my ($bonn, $berlin, $edge) = $graph->add_edge ('Bonn', 'Berlin');

my $boxart = $graph->as_boxart();

like ($boxart, qr/Bonn/, 'contains Bonn');
like ($boxart, qr/Berlin/, 'contains Berlin');
unlike ($boxart, qr/-/, "doesn't contain '-'");

#############################################################################
# border tests

$berlin->set_attribute('border-style', 'dotted');

#############################################################################
# arrow tests

my $open = '──>';
my $closed = '──▷';
my $filled = '──▶';

$boxart = $graph->as_boxart();
like ($boxart, qr/$open/, 'contains edge with open arrow');

$edge->set_attribute('arrow-style', 'open');
$boxart = $graph->as_boxart();
like ($boxart, qr/$open/, 'contains edge with open arrow');

$edge->set_attribute('arrow-style', 'closed');
$boxart = $graph->as_boxart();
like ($boxart, qr/$closed/, 'contains edge with closed arrow');

$edge->set_attribute('arrow-style', 'filled');
$boxart = $graph->as_boxart();
like ($boxart, qr/$filled/, 'contains edge with filled arrow');

#############################################################################
# arrow tests with dotted lines

$open = "··>";
$closed = '··▷';
$filled = '··▶';

$edge->set_attribute('style', 'dotted');
$edge->del_attribute('arrow-style');

is ($edge->style(), 'dotted', 'edge is now dotted');

$boxart = $graph->as_boxart();
like ($boxart, qr/$open/, 'contains edge with open arrow');

$edge->set_attribute('arrow-style', 'open');
$boxart = $graph->as_boxart();
like ($boxart, qr/$open/, 'contains edge with open arrow');

$edge->set_attribute('arrow-style', 'closed');
$boxart = $graph->as_boxart();
like ($boxart, qr/$closed/, 'contains edge with closed arrow');

$edge->set_attribute('arrow-style', 'filled');
$boxart = $graph->as_boxart();
like ($boxart, qr/$filled/, 'contains edge with filled arrow');