Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit ff2c47c

Browse files
Hannah TroisiAdlai Holler
authored andcommitted
add assertion for ASRelativeDimensionTypePercent value to be between 0-1 (#2009)
1 parent 6a21daa commit ff2c47c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

AsyncDisplayKit/Layout/ASDimension.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@
1818
ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type, CGFloat value)
1919
{
2020
if (type == ASRelativeDimensionTypePoints) { ASDisplayNodeCAssertPositiveReal(@"Points", value); }
21+
if (type == ASRelativeDimensionTypePercent) {
22+
ASDisplayNodeCAssert( 0 <= value && value <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", value);
23+
}
2124
ASRelativeDimension dimension; dimension.type = type; dimension.value = value; return dimension;
2225
}
2326

2427
ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points)
2528
{
29+
ASDisplayNodeCAssertPositiveReal(@"Points", points);
2630
return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points);
2731
}
2832

2933
ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent)
3034
{
35+
ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent);
3136
return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent);
3237
}
3338

0 commit comments

Comments
 (0)