Add line sweep algorithm (#4157)

This commit is contained in:
LOne2three
2023-04-19 09:12:30 +01:00
committed by GitHub
parent 1dc388653a
commit 1551b8f50b
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package com.thealgorithms.others;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class LineSweepTest {
@Test
void testForOverlap(){
int[][]arr = {{0,10},{7,20},{15,24}};
assertTrue(LineSweep.isOverlap(arr));
}
@Test
void testForNoOverlap(){
int[][]arr = {{0,10},{11,20},{21,24}};
assertFalse(LineSweep.isOverlap(arr));
}
@Test
void testForOverlapWhenEndAEqualsStartBAndViceVersa(){
int[][]arr = {{0,10},{10,20},{21,24}};
assertTrue(LineSweep.isOverlap(arr));
}
@Test
void testForMaximumEndPoint(){
int[][]arr = {{10,20},{1,100},{14,16},{1,8}};
assertEquals(100,LineSweep.FindMaximumEndPoint(arr));
}
}