summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-05-21 15:08:58 +0200
committerfranck cuny <franck@lumberjaph.net>2011-05-21 15:08:58 +0200
commitf706e1db10a734edaa4eb52ae80adef0a4f4f850 (patch)
tree5a3e7434bfa9c32a57607d467d5b73215f736fb2
parentadd roles for viz and start POD (diff)
downloadgraph-gexf-f706e1db10a734edaa4eb52ae80adef0a4f4f850.tar.gz
add and update tests
Signed-off-by: franck cuny <franck@lumberjaph.net>
-rw-r--r--t/01-basic.t4
-rw-r--r--t/03-node.t11
-rw-r--r--t/04-edges.t12
-rw-r--r--t/08-viz.t31
4 files changed, 48 insertions, 10 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index 8e1a231..6bb7121 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -1,12 +1,16 @@
 use strict;
 use warnings;
+
 use Test::More;
+
 use Graph::GEXF;
 
 ok my $graph = Graph::GEXF->new(), 'graph created';
+
 ok my $n1 = $graph->add_node(), 'node created';
 ok $n1->id, 'node has an id';
 is $graph->total_nodes, 1, 'got one node';
+
 ok my $n2 = $graph->get_node($n1->id);
 
 done_testing;
diff --git a/t/03-node.t b/t/03-node.t
index a3f10e6..448f666 100644
--- a/t/03-node.t
+++ b/t/03-node.t
@@ -1,7 +1,9 @@
 use strict;
 use warnings;
+
 use Test::More;
 use Test::Exception;
+
 use Graph::GEXF::Node;
 
 ok my $node = Graph::GEXF::Node->new(id => 0), 'node created';
@@ -16,13 +18,4 @@ ok $node->set_node_attribute(
 ok $node->attribute('url', 'http://linkfluence.net'),
   'add attribute url to node';
 
-is $node->x, '0.0';
-is $node->y, '0.0';
-
-ok $node->x(5);
-ok $node->y(12);
-
-is $node->x, 5;
-is $node->y, 12;
-
 done_testing;
diff --git a/t/04-edges.t b/t/04-edges.t
index 9ded831..a1e4867 100644
--- a/t/04-edges.t
+++ b/t/04-edges.t
@@ -1,7 +1,17 @@
 use strict;
 use warnings;
+
 use Test::More;
 
-ok 1;
+use Graph::GEXF;
+
+my $graph = Graph::GEXF->new();
+
+my $n1 = $graph->add_node();
+my $n2 = $graph->add_node();
+
+$n1->link_to($n2->id);
+
+ok $n1->has_link_to($n2->id);
 
 done_testing;
diff --git a/t/08-viz.t b/t/08-viz.t
new file mode 100644
index 0000000..c9c6134
--- /dev/null
+++ b/t/08-viz.t
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use Graph::GEXF;
+
+my $graph = Graph::GEXF->new();
+
+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";
+
+sub _test{
+    my ($n, $value, @attr) = @_;
+    foreach (@attr){
+        $n->$_($value);
+    }
+    foreach (@attr){
+        is $n->$_, $value, "property $_ is set to $value";
+    }
+}
+
+done_testing;