Split out structure parsing
Change-Id: Ia38a8c7f588c5361bebbcc7350c18f1540357757
diff --git a/t/annotations-collect.t b/t/annotations-collect.t
new file mode 100644
index 0000000..1a8c45f
--- /dev/null
+++ b/t/annotations-collect.t
@@ -0,0 +1,60 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::XML::Loy;
+
+use FindBin;
+BEGIN {
+ unshift @INC, "$FindBin::Bin/../lib";
+};
+
+use_ok('KorAP::XML::TEI::Annotations::Collector');
+use_ok('KorAP::XML::TEI::Annotations::Annotation');
+
+my $t = KorAP::XML::TEI::Annotations::Collector->new;
+
+$t->add_new_annotation('x1',0,8);
+my $token = $t->add_new_annotation('x2',9,14,2);
+$t->add_new_annotation('x3',15,20);
+
+my $loy = Test::XML::Loy->new($token->to_string(2));
+
+$loy->attr_is('span', 'id', 's2')
+ ->attr_is('span', 'from', 9)
+ ->attr_is('span', 'to', 14)
+ ->attr_is('span', 'l', 2)
+ ->attr_is('span fs f', 'name', 'lex')
+ ;
+
+$loy = Test::XML::Loy->new($t->last_token->to_string(3));
+
+$loy->attr_is('span', 'id', 's3')
+ ->attr_is('span', 'from', 15)
+ ->attr_is('span', 'to', 20)
+ ->attr_is('span fs f', 'name', 'lex')
+;
+
+$loy = Test::XML::Loy->new($t->to_string('text', 0))
+ ->attr_is('layer', 'docid', 'text')
+ ->attr_is('span#s0', 'to', '8')
+ ->attr_is('span#s1', 'to', '14')
+ ->attr_is('span#s1', 'l', '2')
+ ->attr_is('span#s2', 'to', '20')
+;
+
+my $anno = KorAP::XML::TEI::Annotations::Annotation->new('x4', 20 => 21);
+
+$t->add_annotation($anno);
+
+$loy = Test::XML::Loy->new($t->to_string('text',0))
+ ->attr_is('layer', 'docid', 'text')
+ ->attr_is('span#s0', 'to', '8')
+ ->attr_is('span#s1', 'to', '14')
+ ->attr_is('span#s1', 'l', '2')
+ ->attr_is('span#s2', 'to', '20')
+ ->attr_is('span#s3', 'from', '20')
+ ->attr_is('span#s3', 'to', '21')
+;
+
+done_testing;
+