package Ġtests . basic Ċ Ċ import Ġio . fluid sonic . json .* Ċ import Ġjava . io .* Ċ import Ġkotlin . test .* ĊĊ Ċ class ĠJson Writer Test Ġ{ ĊĊ ĉ @ Test Ċ ĉ fun Ġtest WithError Checking () Ġ{ Ċĉ ĉ val Ġwriter Ġ= ĠJson Writer . build ( String Writer ()) Ċĉ ĉ expect ( writer . is Er rored ). toBe ( false ) Ċĉ ĉ expect ( writer . with Error Checking Ġ{ Ġ" test " Ġ}). toBe (" test ") Ċĉ ĉ expect ( writer . is Er rored ). toBe ( false ) ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ if Ġ( 0 . to BigDecimal () Ġ== Ġ 0 . to BigDecimal ()) Ġwriter . with Error Checking Ġ{ Ġthrow ĠRuntimeException () Ġ} Ċĉĉ ĉ throw ĠAssertionError (". with Error Checking () Ġshould Ġnot Ġconsume Ġexception ") Ċĉ ĉ } Ċĉ ĉ catch Ġ( e : ĠThrowable ) Ġ{ Ċĉĉ ĉ expect ( writer . is Er rored ). toBe ( true ) Ċĉ ĉ } ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ writer . with Error Checking Ġ{ Ġ} Ċĉĉ ĉ throw ĠAssertionError (". with Error Checking () Ġthrow Ġwhen Ġerro red ") Ċĉ ĉ } Ċĉ ĉ catch Ġ( e : ĠJson Exception ) Ġ{ Ċĉĉ ĉ expect ( writer . is Er rored ). toBe ( true ) Ċĉ ĉ } Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest Default Write Deleg ations () Ġ{ Ċĉ ĉ var Ġdouble Value : ĠDouble ? Ġ= Ġnull Ċĉ ĉ var Ġlong Value : ĠLong ? Ġ= Ġnull Ċĉ ĉ var Ġstring Value : ĠString ? Ġ= Ġnull ĊĊĉ ĉ val Ġwriter Ġ= Ġobject Ġ: ĠDummy Json Writer () Ġ{ ĊĊĉĉ ĉ override Ġfun Ġwrite Double ( value : ĠDouble ) Ġ{ Ċĉĉĉ ĉ doubleValue Ġ= Ġvalue Ċĉĉ ĉ } ĊĊĉĉ ĉ override Ġfun Ġwrite Long ( value : ĠLong ) Ġ{ Ċĉĉĉ ĉ longValue Ġ= Ġvalue Ċĉĉ ĉ } ĊĊĉĉ ĉ override Ġfun Ġwrite String ( value : ĠString ) Ġ{ Ċĉĉĉ ĉ stringValue Ġ= Ġvalue Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ writer . write Byte ( 1 ) Ċĉ ĉ expect ( longValue ). toBe ( 1 L ) ĊĊĉ ĉ writer . write Float ( 2 . 0 f ) Ċĉ ĉ expect ( doubleValue ). toBe ( 2 . 0 ) ĊĊĉ ĉ writer . writeInt ( 3 ) Ċĉ ĉ expect ( longValue ). toBe ( 3 ) ĊĊĉ ĉ writer . write Map Key (" 4 ") Ċĉ ĉ expect ( stringValue ). toBe (" 4 ") ĊĊĉ ĉ writer . write Short ( 5 ) Ċĉ ĉ expect ( longValue ). toBe ( 5 ) Ċ ĉ } Ċ } Ċ