summaryrefslogtreecommitdiff
path: root/t/08-viz.t
blob: 33555ee409618c2b7542ee4583f763876f8ca68e (plain) (blame)
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
use strict;
use warnings;

use Test::More;
use Test::Exception;

use Graph::GEXF;

my $graph = Graph::GEXF->new(visualization => 1);

my $n = $graph->add_node();

# position
_test($n, 1, qw/x y z/);
_test($n, 1, qw/r g b/);

# colors
dies_ok {$n->r(256)} "can't set color to value > 255";
dies_ok {$n->r(-1)} "can't set color to value < 0";

my $n2 = $graph->add_node();
$n->link_to($n2->id);

my $xml = $graph->to_xml;

sub _test{
    my ($n, $value, @attr) = @_;
    foreach (@attr){
        $n->$_($value);
    }
    foreach (@attr){
        is $n->$_, $value, "property $_ is set to $value";
    }
}

done_testing;