@@ -114,6 +114,42 @@ class AdjustSizeSpec: QuickSpec {
114114 aView. pin. width ( of: aViewChild)
115115 expect ( aView. frame) . to ( equal ( CGRect ( x: 140.0 , y: 100.0 , width: 50.0 , height: 60.0 ) ) )
116116 }
117+
118+ it ( " should accept a width of 0 " ) {
119+ aView. pin. width ( 0 )
120+ expect ( Pin . lastWarningText) . to ( beNil ( ) )
121+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 0.0 , height: 60.0 ) ) )
122+ }
123+
124+ it ( " should warn about negative width value " ) {
125+ aView. pin. width ( - 2 )
126+ expect ( Pin . lastWarningText) . to ( contain ( [ " width " , " won't be applied " , " the width " , " must be greater than or equal to zero " ] ) )
127+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
128+ }
129+
130+ it ( " should warn about NaN width value " ) {
131+ aView. pin. width ( CGFloat . nan)
132+ expect ( Pin . lastWarningText) . to ( contain ( [ " width " , " nan " , " won't be applied " , " the width " , " must be greater than or equal to zero " ] ) )
133+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
134+ }
135+
136+ it ( " should warn about -NaN width value " ) {
137+ aView. pin. width ( - CGFloat. nan)
138+ expect ( Pin . lastWarningText) . to ( contain ( [ " width " , " nan " , " won't be applied " , " the width " , " must be greater than or equal to zero " ] ) )
139+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
140+ }
141+
142+ it ( " should warn about infinity width value " ) {
143+ aView. pin. width ( CGFloat . infinity)
144+ expect ( Pin . lastWarningText) . to ( contain ( [ " width " , " inf " , " won't be applied " , " the width " , " must be greater than or equal to zero " ] ) )
145+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
146+ }
147+
148+ it ( " should warn about -infinity width value " ) {
149+ aView. pin. width ( - CGFloat. infinity)
150+ expect ( Pin . lastWarningText) . to ( contain ( [ " width " , " inf " , " won't be applied " , " the width " , " must be greater than or equal to zero " ] ) )
151+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
152+ }
117153 }
118154
119155 describe ( " the result of the height(...) methods " ) {
@@ -147,6 +183,42 @@ class AdjustSizeSpec: QuickSpec {
147183 aView. pin. height ( of: aViewChild)
148184 expect ( aView. frame) . to ( equal ( CGRect ( x: 140.0 , y: 100.0 , width: 100.0 , height: 30.0 ) ) )
149185 }
186+
187+ it ( " should accept a height of 0 " ) {
188+ aView. pin. height ( 0 )
189+ expect ( Pin . lastWarningText) . to ( beNil ( ) )
190+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 0.0 ) ) )
191+ }
192+
193+ it ( " should warn about negative height value " ) {
194+ aView. pin. height ( - 2 )
195+ expect ( Pin . lastWarningText) . to ( contain ( [ " height " , " won't be applied " , " the height " , " must be greater than or equal to zero " ] ) )
196+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
197+ }
198+
199+ it ( " should warn about NaN height value " ) {
200+ aView. pin. height ( CGFloat . nan)
201+ expect ( Pin . lastWarningText) . to ( contain ( [ " height " , " nan " , " won't be applied " , " the height " , " must be greater than or equal to zero " ] ) )
202+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
203+ }
204+
205+ it ( " should warn about -NaN height value " ) {
206+ aView. pin. height ( - CGFloat. nan)
207+ expect ( Pin . lastWarningText) . to ( contain ( [ " height " , " nan " , " won't be applied " , " the height " , " must be greater than or equal to zero " ] ) )
208+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
209+ }
210+
211+ it ( " should warn about infinity height value " ) {
212+ aView. pin. height ( CGFloat . infinity)
213+ expect ( Pin . lastWarningText) . to ( contain ( [ " height " , " inf " , " won't be applied " , " the height " , " must be greater than or equal to zero " ] ) )
214+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
215+ }
216+
217+ it ( " should warn about -infinity height value " ) {
218+ aView. pin. height ( - CGFloat. infinity)
219+ expect ( Pin . lastWarningText) . to ( contain ( [ " height " , " inf " , " won't be applied " , " the height " , " must be greater than or equal to zero " ] ) )
220+ expect ( aView. frame) . to ( equal ( CGRect ( x: 140 , y: 100.0 , width: 100.0 , height: 60.0 ) ) )
221+ }
150222 }
151223
152224 describe ( " the result of the size(...) methods " ) {
0 commit comments