From ff2c47c415ce4019db0c44598980d46073f2badd Mon Sep 17 00:00:00 2001 From: Hannah Troisi Date: Fri, 29 Jul 2016 10:38:20 -0700 Subject: [PATCH] add assertion for ASRelativeDimensionTypePercent value to be between 0-1 (#2009) --- AsyncDisplayKit/Layout/ASDimension.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AsyncDisplayKit/Layout/ASDimension.mm b/AsyncDisplayKit/Layout/ASDimension.mm index 53b03b7670..cf58e1c517 100644 --- a/AsyncDisplayKit/Layout/ASDimension.mm +++ b/AsyncDisplayKit/Layout/ASDimension.mm @@ -18,16 +18,21 @@ ASRelativeDimension const ASRelativeDimensionUnconstrained = {}; ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type, CGFloat value) { if (type == ASRelativeDimensionTypePoints) { ASDisplayNodeCAssertPositiveReal(@"Points", value); } + if (type == ASRelativeDimensionTypePercent) { + ASDisplayNodeCAssert( 0 <= value && value <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", value); + } ASRelativeDimension dimension; dimension.type = type; dimension.value = value; return dimension; } ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points) { + ASDisplayNodeCAssertPositiveReal(@"Points", points); return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points); } ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent) { + ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent); return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent); }