@@ -474,14 +474,15 @@ void main() {
474
474
test ('empty spans' , () {
475
475
// Make sure no exceptions are thrown when collapsing
476
476
// spans on an empty AttributedSpans.
477
- AttributedSpans ().collapseSpans (contentLength: 0 );
477
+ final spans = AttributedSpans ().collapseSpans (contentLength: 0 );
478
+ expect (spans, isEmpty);
478
479
});
479
480
480
481
test ('non-empty span with no attributions' , () {
481
482
final collapsedSpans = AttributedSpans ().collapseSpans (contentLength: 10 );
482
483
expect (collapsedSpans, hasLength (1 ));
483
484
expect (collapsedSpans.first.start, 0 );
484
- expect (collapsedSpans.first.end, 9 );
485
+ expect (collapsedSpans.first.end, 10 );
485
486
expect (collapsedSpans.first.attributions, isEmpty);
486
487
});
487
488
@@ -491,7 +492,7 @@ void main() {
491
492
const SpanMarker (attribution: ExpectedSpans .bold, offset: 0 , markerType: SpanMarkerType .start),
492
493
const SpanMarker (attribution: ExpectedSpans .bold, offset: 16 , markerType: SpanMarkerType .end),
493
494
],
494
- ).collapseSpans (contentLength: 17 );
495
+ ).collapseSpans (contentLength: 16 );
495
496
496
497
expect (collapsedSpans.length, 1 );
497
498
expect (collapsedSpans.first.start, 0 );
@@ -508,21 +509,21 @@ void main() {
508
509
const SpanMarker (attribution: ExpectedSpans .bold, offset: 7 , markerType: SpanMarkerType .start),
509
510
const SpanMarker (attribution: ExpectedSpans .bold, offset: 10 , markerType: SpanMarkerType .end),
510
511
],
511
- ).collapseSpans (contentLength: 17 );
512
+ ).collapseSpans (contentLength: 16 );
512
513
513
514
expect (collapsedSpans.length, 4 );
514
515
expect (collapsedSpans[0 ].start, 0 );
515
516
expect (collapsedSpans[0 ].end, 3 );
516
517
expect (collapsedSpans[0 ].attributions.length, 1 );
517
518
expect (collapsedSpans[0 ].attributions.first, ExpectedSpans .bold);
518
- expect (collapsedSpans[1 ].start, 4 );
519
- expect (collapsedSpans[1 ].end, 6 );
519
+ expect (collapsedSpans[1 ].start, 3 );
520
+ expect (collapsedSpans[1 ].end, 7 );
520
521
expect (collapsedSpans[1 ].attributions.length, 0 );
521
522
expect (collapsedSpans[2 ].start, 7 );
522
523
expect (collapsedSpans[2 ].end, 10 );
523
524
expect (collapsedSpans[2 ].attributions.length, 1 );
524
525
expect (collapsedSpans[2 ].attributions.first, ExpectedSpans .bold);
525
- expect (collapsedSpans[3 ].start, 11 );
526
+ expect (collapsedSpans[3 ].start, 10 );
526
527
expect (collapsedSpans[3 ].end, 16 );
527
528
expect (collapsedSpans[3 ].attributions.length, 0 );
528
529
});
@@ -531,17 +532,17 @@ void main() {
531
532
final collapsedSpans = AttributedSpans (
532
533
attributions: [
533
534
const SpanMarker (attribution: ExpectedSpans .bold, offset: 0 , markerType: SpanMarkerType .start),
534
- const SpanMarker (attribution: ExpectedSpans .bold, offset: 4 , markerType: SpanMarkerType .end),
535
+ const SpanMarker (attribution: ExpectedSpans .bold, offset: 5 , markerType: SpanMarkerType .end),
535
536
const SpanMarker (attribution: ExpectedSpans .italics, offset: 5 , markerType: SpanMarkerType .start),
536
- const SpanMarker (attribution: ExpectedSpans .italics, offset: 9 , markerType: SpanMarkerType .end),
537
+ const SpanMarker (attribution: ExpectedSpans .italics, offset: 10 , markerType: SpanMarkerType .end),
537
538
],
538
539
).collapseSpans (contentLength: 10 );
539
540
540
541
expect (collapsedSpans, hasLength (2 ));
541
542
expect (collapsedSpans.first.start, 0 );
542
- expect (collapsedSpans.first.end, 4 );
543
+ expect (collapsedSpans.first.end, 5 );
543
544
expect (collapsedSpans.last.start, 5 );
544
- expect (collapsedSpans.last.end, 9 );
545
+ expect (collapsedSpans.last.end, 10 );
545
546
});
546
547
547
548
test ('multiple non-overlapping attributions' , () {
@@ -552,21 +553,21 @@ void main() {
552
553
const SpanMarker (attribution: ExpectedSpans .italics, offset: 7 , markerType: SpanMarkerType .start),
553
554
const SpanMarker (attribution: ExpectedSpans .italics, offset: 10 , markerType: SpanMarkerType .end),
554
555
],
555
- ).collapseSpans (contentLength: 17 );
556
+ ).collapseSpans (contentLength: 16 );
556
557
557
558
expect (collapsedSpans.length, 4 );
558
559
expect (collapsedSpans[0 ].start, 0 );
559
560
expect (collapsedSpans[0 ].end, 3 );
560
561
expect (collapsedSpans[0 ].attributions.length, 1 );
561
562
expect (collapsedSpans[0 ].attributions.first, ExpectedSpans .bold);
562
- expect (collapsedSpans[1 ].start, 4 );
563
- expect (collapsedSpans[1 ].end, 6 );
563
+ expect (collapsedSpans[1 ].start, 3 );
564
+ expect (collapsedSpans[1 ].end, 7 );
564
565
expect (collapsedSpans[1 ].attributions.length, 0 );
565
566
expect (collapsedSpans[2 ].start, 7 );
566
567
expect (collapsedSpans[2 ].end, 10 );
567
568
expect (collapsedSpans[2 ].attributions.length, 1 );
568
569
expect (collapsedSpans[2 ].attributions.first, ExpectedSpans .italics);
569
- expect (collapsedSpans[3 ].start, 11 );
570
+ expect (collapsedSpans[3 ].start, 10 );
570
571
expect (collapsedSpans[3 ].end, 16 );
571
572
expect (collapsedSpans[3 ].attributions.length, 0 );
572
573
});
@@ -579,18 +580,18 @@ void main() {
579
580
const SpanMarker (attribution: ExpectedSpans .italics, offset: 6 , markerType: SpanMarkerType .start),
580
581
const SpanMarker (attribution: ExpectedSpans .italics, offset: 16 , markerType: SpanMarkerType .end),
581
582
],
582
- ).collapseSpans (contentLength: 17 );
583
+ ).collapseSpans (contentLength: 16 );
583
584
584
585
expect (collapsedSpans.length, 3 );
585
586
expect (collapsedSpans[0 ].start, 0 );
586
- expect (collapsedSpans[0 ].end, 5 );
587
+ expect (collapsedSpans[0 ].end, 6 );
587
588
expect (collapsedSpans[0 ].attributions.length, 1 );
588
589
expect (collapsedSpans[0 ].attributions.first, ExpectedSpans .bold);
589
590
expect (collapsedSpans[1 ].start, 6 );
590
591
expect (collapsedSpans[1 ].end, 8 );
591
592
expect (collapsedSpans[1 ].attributions.length, 2 );
592
593
expect (collapsedSpans[1 ].attributions, equals ({ExpectedSpans .bold, ExpectedSpans .italics}));
593
- expect (collapsedSpans[2 ].start, 9 );
594
+ expect (collapsedSpans[2 ].start, 8 );
594
595
expect (collapsedSpans[2 ].end, 16 );
595
596
expect (collapsedSpans[2 ].attributions.length, 1 );
596
597
expect (collapsedSpans[2 ].attributions.first, ExpectedSpans .italics);
0 commit comments