@@ -151,7 +151,7 @@ public void numericZeroToBooleanCoercion(TagMapType mapType) {
151151 .set ("floatObj" , Float .valueOf (0F ))
152152 .set ("double" , 0D )
153153 .set ("doubleObj" , Double .valueOf (0D ))
154- .build ();
154+ .build (mapType . factory );
155155
156156 assertEquals (false , map .getBoolean ("int" ));
157157 assertEquals (false , map .getBoolean ("intObj" ));
@@ -176,7 +176,7 @@ public void numericNonZeroToBooleanCoercion(TagMapType mapType) {
176176 .set ("floatObj" , Float .valueOf (1F ))
177177 .set ("double" , 1D )
178178 .set ("doubleObj" , Double .valueOf (1D ))
179- .build ();
179+ .build (mapType . factory );
180180
181181 assertEquals (true , map .getBoolean ("int" ));
182182 assertEquals (true , map .getBoolean ("intObj" ));
@@ -196,13 +196,47 @@ public void objectToBooleanCoercion(TagMapType mapType) {
196196 .set ("obj" , new Object ())
197197 .set ("trueStr" , "true" )
198198 .set ("falseStr" , "false" )
199- .build ();
199+ .build (mapType . factory );
200200
201201 assertEquals (true , map .getBoolean ("obj" ));
202202 assertEquals (true , map .getBoolean ("trueStr" ));
203203 assertEquals (true , map .getBoolean ("falseStr" ));
204204 }
205205
206+ @ ParameterizedTest
207+ @ EnumSource (TagMapType .class )
208+ public void booleanToNumericCoercion_true (TagMapType mapType ) {
209+ TagMap map = TagMap .ledger ().set ("true" , true ).build (mapType .factory );
210+
211+ assertEquals (1 , map .getInt ("true" ));
212+ assertEquals (1L , map .getLong ("true" ));
213+ assertEquals (1F , map .getFloat ("true" ));
214+ assertEquals (1D , map .getDouble ("true" ));
215+ }
216+
217+ @ ParameterizedTest
218+ @ EnumSource (TagMapType .class )
219+ public void booleanToNumericCoercion_false (TagMapType mapType ) {
220+ TagMap map = TagMap .ledger ().set ("false" , false ).build (mapType .factory );
221+
222+ assertEquals (0 , map .getInt ("false" ));
223+ assertEquals (0L , map .getLong ("false" ));
224+ assertEquals (0F , map .getFloat ("false" ));
225+ assertEquals (0D , map .getDouble ("false" ));
226+ }
227+
228+ @ ParameterizedTest
229+ @ EnumSource (TagMapType .class )
230+ public void emptyToPrimitiveCoercion (TagMapType mapType ) {
231+ TagMap map = mapType .empty ();
232+
233+ assertEquals (false , map .getBoolean ("dne" ));
234+ assertEquals (0 , map .getInt ("dne" ));
235+ assertEquals (0L , map .getLong ("dne" ));
236+ assertEquals (0F , map .getFloat ("dne" ));
237+ assertEquals (0D , map .getDouble ("dne" ));
238+ }
239+
206240 @ ParameterizedTest
207241 @ EnumSource (TagMapType .class )
208242 public void intEntry (TagMapType mapType ) {
0 commit comments