X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition_collation_relationshipstore.t;h=9f9ed65acbc64cae8b03d08001f637ca2c79367b;hb=a2ed66b255a1b88374b5279faa18f0c390ca5dbb;hp=f09e2458e49d760ab5a8f9ea83c1e0c560e6c561;hpb=b0b4421ad99abdb67e413f16219e932576212e50;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition_collation_relationshipstore.t b/t/text_tradition_collation_relationshipstore.t index f09e245..9f9ed65 100644 --- a/t/text_tradition_collation_relationshipstore.t +++ b/t/text_tradition_collation_relationshipstore.t @@ -9,8 +9,33 @@ $| = 1; # =begin testing { use Text::Tradition; +use TryCatch; use_ok( 'Text::Tradition::Collation::RelationshipStore' ); + +# Add some relationships, and delete them + +my $cxfile = 't/data/Collatex-16.xml'; +my $t = Text::Tradition->new( + 'name' => 'inline', + 'input' => 'CollateX', + 'file' => $cxfile, + ); +my $c = $t->collation; + +my @v1 = $c->add_relationship( 'n21', 'n22', { 'type' => 'meaning' } ); +is( scalar @v1, 1, "Added a single relationship" ); +is( $v1[0]->[0], 'n21', "Got correct node 1" ); +is( $v1[0]->[1], 'n22', "Got correct node 2" ); +my @v2 = $c->add_relationship( 'n9', 'n23', + { 'type' => 'spelling', 'scope' => 'global' } ); +is( scalar @v2, 2, "Added a global relationship with two instances" ); +@v1 = $c->del_relationship( 'n22', 'n21' ); +is( scalar @v1, 1, "Deleted first relationship" ); +@v2 = $c->del_relationship( 'n8', 'n13' ); +is( scalar @v2, 2, "Deleted second global relationship" ); +my @v3 = $c->del_relationship( 'n1', 'n2' ); +is( scalar @v3, 0, "Nothing deleted on non-existent relationship" ); }