Skip to content

Commit

Permalink
Merge pull request #12 from vmartinv/mentioned_range
Browse files Browse the repository at this point in the history
Handle Range as Part in mentionedRange
  • Loading branch information
sylvainhalle authored Nov 7, 2023
2 parents a895ca0 + 530faf9 commit 4b07d35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ public int compareTo(Range r)
/*@ null @*/ public static Range mentionedRange(Part d)
{
Range r = null;
if (d instanceof ComposedPart)
if(d instanceof Range){
r = (Range)d;
}
else if (d instanceof ComposedPart)
{
ComposedPart cd = (ComposedPart) d;
for (int i = cd.size() - 1; i >= 0; i--)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import org.junit.Test;

import ca.uqac.lif.petitpoucet.Part;

/**
* Unit tests for {@link Range}.
*/
Expand Down Expand Up @@ -95,4 +97,11 @@ public void testOverlap7()
assertEquals(o, r1.overlaps(r2));
assertEquals(o, r2.overlaps(r1));
}

@Test
public void testMentionedRange()
{
Range r = new Range(3, 8);
assertEquals(r, Range.mentionedRange((Part)r));
}
}

0 comments on commit 4b07d35

Please sign in to comment.