Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
289Adam289 committed Dec 11, 2024
1 parent 0d8327e commit cea5128
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public static void splitRangesOnEmojis(List<MarkdownRange> markdownRanges, Strin
}

// Split range
while(j < emojiRanges.size()){
while (j < emojiRanges.size()) {
MarkdownRange emojiRange = emojiRanges.get(j);
if(emojiRange.getStart() > currentRange.getEnd()) break;
if (emojiRange.getStart() > currentRange.getEnd()) break;

if (emojiRange.getStart() >= currentRange.getStart() && emojiRange.getEnd() <= currentRange.getEnd()) {
MarkdownRange newRange = new MarkdownRange(currentRange.getType(), currentRange.getStart(), emojiRange.getStart() - currentRange.getStart(), currentRange.getDepth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class RangeSplitterTest {

private void testRange(MarkdownRange range, int start, int end, String type){
private void testRange(MarkdownRange range, int start, int end, String type) {
assertEquals(start, range.getStart());
assertEquals(end, range.getEnd());
assertEquals(type, range.getType());
Expand All @@ -23,7 +23,7 @@ private void testRange(MarkdownRange range, int start, int end, String type){
public void testNoOverlap() {
List<MarkdownRange> markdownRanges = new ArrayList<>();
markdownRanges.add(new MarkdownRange("strikethrough", 0, 10, 1));
markdownRanges.add(new MarkdownRange("emoji", 12, 2,1));
markdownRanges.add(new MarkdownRange("emoji", 12, 2, 1));

splitRangesOnEmojis(markdownRanges, "strikethrough");

Expand All @@ -47,7 +47,7 @@ public void testOverlapWrongType() {
}

@Test
public void testSingleOverlap(){
public void testSingleOverlap() {
List<MarkdownRange> markdownRanges = new ArrayList<>();
markdownRanges.add(new MarkdownRange("strikethrough", 0, 10, 1));
markdownRanges.add(new MarkdownRange("emoji", 3, 4, 1)); // This should split the strikethrough range
Expand All @@ -58,13 +58,13 @@ public void testSingleOverlap(){
Collections.sort(markdownRanges, (r1, r2) -> Integer.compare(r1.getStart(), r2.getStart()));

assertEquals(3, markdownRanges.size());
testRange(markdownRanges.get(0), 0 ,3, "strikethrough");
testRange(markdownRanges.get(1), 3 ,7, "emoji");
testRange(markdownRanges.get(2), 7 ,10, "strikethrough");
testRange(markdownRanges.get(0), 0, 3, "strikethrough");
testRange(markdownRanges.get(1), 3, 7, "emoji");
testRange(markdownRanges.get(2), 7, 10, "strikethrough");
}

@Test
public void testMultipleOverlapsMultipleTypes(){
public void testMultipleOverlapsMultipleTypes() {
List<MarkdownRange> markdownRanges = new ArrayList<>();
markdownRanges.add(new MarkdownRange("italic", 0, 20, 1));
markdownRanges.add(new MarkdownRange("strikethrough", 2, 12, 1));
Expand All @@ -78,12 +78,12 @@ public void testMultipleOverlapsMultipleTypes(){
Collections.sort(markdownRanges, (r1, r2) -> Integer.compare(r1.getStart(), r2.getStart()));

assertEquals(7, markdownRanges.size());
testRange(markdownRanges.get(0), 0 ,20, "italic");
testRange(markdownRanges.get(1), 2 ,3, "strikethrough");
testRange(markdownRanges.get(2), 3 ,4, "emoji");
testRange(markdownRanges.get(3), 4 , 8, "strikethrough");
testRange(markdownRanges.get(4), 8 ,10, "emoji");
testRange(markdownRanges.get(5), 10 ,14, "strikethrough");
testRange(markdownRanges.get(6), 22 ,27, "strikethrough");
testRange(markdownRanges.get(0), 0, 20, "italic");
testRange(markdownRanges.get(1), 2, 3, "strikethrough");
testRange(markdownRanges.get(2), 3, 4, "emoji");
testRange(markdownRanges.get(3), 4, 8, "strikethrough");
testRange(markdownRanges.get(4), 8, 10, "emoji");
testRange(markdownRanges.get(5), 10, 14, "strikethrough");
testRange(markdownRanges.get(6), 22, 27, "strikethrough");
}
}

0 comments on commit cea5128

Please sign in to comment.