Skip to content

Commit 18108dd

Browse files
committed
TESTING - Refactor test logic to test less points and prevent invalid point calculations by using a fixed quantity. The tests were taking 20-30 seconds each, these should be fast.
1 parent 0649371 commit 18108dd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sf-iosTests/sweep/ShamosHoeyTestCase.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,11 @@ - (void)testExternalHole {
462462

463463
- (void)testLargeSimple {
464464

465-
double increment = .01;
466-
double radius = 1250;
465+
double increment = .07;
466+
double radius = 127;
467467
double x = -radius + increment;
468468
double y = 0;
469+
int expectedPoints = 7256;
469470

470471
NSMutableArray<SFPoint *> *points = [NSMutableArray array];
471472

@@ -495,17 +496,18 @@ - (void)testLargeSimple {
495496
[SFTestUtils assertTrue:[SFShamosHoey simplePolygon:[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]]]];
496497
[SFTestUtils assertTrue:[[SFLineString lineStringWithPoints:points] isSimple]];
497498
[SFTestUtils assertTrue:[[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]] isSimple]];
498-
[SFTestUtils assertEqualIntWithValue:(int) (radius / increment * 4) andValue2:(int)points.count];
499+
[SFTestUtils assertEqualIntWithValue:expectedPoints andValue2:(int)points.count];
499500

500501
}
501502

502503
- (void)testLargeNonSimple {
503504

504-
double increment = .01;
505-
double radius = 1250;
505+
double increment = .07;
506+
double radius = 127;
506507
double x = -radius + increment;
507508
double y = 0;
508-
509+
int expectedPoints = 7257;
510+
509511
NSMutableArray<SFPoint *> *points = [NSMutableArray array];
510512

511513
while (x <= radius) {
@@ -538,7 +540,7 @@ - (void)testLargeNonSimple {
538540
[SFTestUtils assertFalse:[SFShamosHoey simplePolygon:[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]]]];
539541
[SFTestUtils assertFalse:[[SFLineString lineStringWithPoints:points] isSimple]];
540542
[SFTestUtils assertFalse:[[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]] isSimple]];
541-
[SFTestUtils assertEqualIntWithValue:1 + (int) (radius / increment * 4) andValue2:(int)points.count];
543+
[SFTestUtils assertEqualIntWithValue:expectedPoints andValue2:(int)points.count];
542544

543545
[points removeObjectAtIndex:invalidIndex];
544546
previousPoint = [points objectAtIndex:points.count - 3];
@@ -549,7 +551,7 @@ - (void)testLargeNonSimple {
549551
[SFTestUtils assertFalse:[SFShamosHoey simplePolygon:[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]]]];
550552
[SFTestUtils assertFalse:[[SFLineString lineStringWithPoints:points] isSimple]];
551553
[SFTestUtils assertFalse:[[SFPolygon polygonWithRing:[SFLineString lineStringWithPoints:points]] isSimple]];
552-
[SFTestUtils assertEqualIntWithValue:1 + (int) (radius / increment * 4) andValue2:(int)points.count];
554+
[SFTestUtils assertEqualIntWithValue:expectedPoints andValue2:(int)points.count];
553555

554556
}
555557

0 commit comments

Comments
 (0)