package Ġru . cap jack . tool . lang Ċ Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertEquals Ċ Ċ @ Suppress (" Spell Checking Inspection ") Ċ class ĠTest Hex Ġ{ Ċ ĉ @ Test Ċ ĉ fun Ġbyte _ to _ hex _ string () Ġ{ Ċĉ ĉ assertEquals (" 0 0 ", Ġ 0 . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" 0 1 ", Ġ 1 . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" 0 7 ", Ġ 0 x 0 7 . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" 0 f ", Ġ 0 x 0 F . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" 8 0 ", Ġ 0 x 8 0 . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" f 0 ", Ġ 0 xF 0 . to Byte (). to HexString ()) Ċĉ ĉ assertEquals (" ff ", Ġ 0 xFF . to Byte (). to HexString ()) Ċ ĉ } ĊĉĊ ĉ @ Test Ċ ĉ fun Ġbyte _ to _ hex _ string _ append able () Ġ{ ĊĉĉĊĉ ĉ val Ġvalues Ġ= Ġbyte ArrayOf ( 0 , Ġ 1 , Ġ 0 x 0 7 , Ġ 0 x 0 F , Ġ 0 x 8 0 . to Byte (), Ġ 0 xF 0 . to Byte (), Ġ 0 xFF . to Byte ()) Ċĉ ĉ val Ġtarget Ġ= ĠStringBuilder () ĊĉĉĊĉ ĉ values . forEach Ġ{ Ġit . to HexString ( target ) Ġ} ĊĉĉĊĉ ĉ assertEquals (" 0 0 " Ġ+ Ġ" 0 1 " Ġ+ Ġ" 0 7 " Ġ+ Ġ" 0 f " Ġ+ Ġ" 8 0 " Ġ+ Ġ" f 0 " Ġ+ Ġ" ff ", Ġtarget . toString ()) Ċ ĉ } ĊĉĊ ĉ @ Test Ċ ĉ fun Ġint _ to _ hex _ string () Ġ{ Ċĉ ĉ assertEquals (" 0 0 0 0 0 0 0 0 ", Ġ 0 . to HexString ()) Ċĉ ĉ assertEquals (" 0 0 0 0 0 0 0 1 ", Ġ 1 . to HexString ()) Ċĉ ĉ assertEquals (" 0 0 0 0 7 fff ", Ġ 0 x 7 FFF . to HexString ()) Ċĉ ĉ assertEquals (" 0 0 0 0 8 0 0 0 ", Ġ 0 x 8 0 0 0 . to HexString ()) Ċĉ ĉ assertEquals (" 7 fffffff ", Ġ 0 x 7 FFFF FFF . to HexString ()) Ċĉ ĉ assertEquals (" 8 0 0 0 0 0 0 0 ", Ġ 0 x 8 0 0 0 0 0 0 0 . toInt (). to HexString ()) Ċĉ ĉ assertEquals (" ffff 0 0 0 0 ", Ġ 0 xFFFF 0 0 0 0 . toInt (). to HexString ()) Ċĉ ĉ assertEquals (" ffffffff ", Ġ 0 xFFFFFFFF . toInt (). to HexString ()) Ċ ĉ } ĊĉĊĉĊ ĉ @ Test Ċ ĉ fun Ġint _ to _ hex _ string _ append able () Ġ{ ĊĉĉĊĉ ĉ val Ġvalues Ġ= Ġint ArrayOf ( 0 , Ġ 1 , Ġ 0 x 7 FFF , Ġ 0 x 8 0 0 0 , Ġ 0 x 7 FFFF FFF , Ġ 0 x 8 0 0 0 0 0 0 0 . toInt (), Ġ 0 xFFFF 0 0 0 0 . toInt (), Ġ 0 xFFFFFFFF . toInt ()) Ċĉ ĉ val Ġtarget Ġ= ĠStringBuilder () ĊĉĉĊĉ ĉ values . forEach Ġ{ Ġit . to HexString ( target ) Ġ} ĊĉĉĊĉ ĉ assertEquals ( Ċĉĉ ĉ " 0 0 0 0 0 0 0 0 " Ġ+ Ċĉĉĉ ĉ " 0 0 0 0 0 0 0 1 " Ġ+ Ċĉĉĉ ĉ " 0 0 0 0 7 fff " Ġ+ Ċĉĉĉ ĉ " 0 0 0 0 8 0 0 0 " Ġ+ Ċĉĉĉ ĉ " 7 fffffff " Ġ+ Ċĉĉĉ ĉ " 8 0 0 0 0 0 0 0 " Ġ+ Ċĉĉĉ ĉ " ffff 0 0 0 0 " Ġ+ Ċĉĉĉ ĉ " ffffffff ", Ċĉĉ ĉ target . toString () Ċĉ ĉ ) Ċ ĉ } Ċ }