package Ġfr . ac in q . lightning . utils Ċ Ċ import Ġfr . ac in q . lightning . tests . utils . Lightning TestSuite Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠBit Fields Common Ġ: ĠLight ning TestSuite () Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Creation Ġand Ġsimple Ġget Ġand Ġset Ġfrom Ġleft `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbs Ġ= ĠBit Field ( 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 0 0 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 0 0 0 0 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Left ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Left ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . set Left ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 4 0 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 1 0 0 0 0 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Left ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Left ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . set Left ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 6 0 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 1 1 0 0 0 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Left ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Left ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . clear Left ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 2 0 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 1 0 0 0 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Left ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Left ( 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Creation Ġand Ġsimple Ġget Ġand Ġset Ġfrom Ġright `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbs Ġ= ĠBit Field ( 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 0 0 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 0 0 0 0 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Right ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Right ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . set Right ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 0 2 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 0 0 0 0 1 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Right ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Right ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . set Right ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 0 6 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 0 0 0 1 1 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Right ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Right ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġbs . clear Right ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 0 4 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 0 0 0 0 1 0 0 ", Ġbs . to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġbs . get Right ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġbs . get Right ( 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Re version Ġof Ġa ĠbitField `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbs Ġ= ĠBit Field . from ( byte ArrayOf ( 0 x 6 0 , Ġ 0 x 0 1 )) ĊĠĠĠĠĠĠĠ Ġval Ġr bs Ġ= Ġbs . reversed () ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 6 0 0 1 ", Ġbs . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 0 x 8 0 0 6 ", Ġr bs . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Creation Ġfrom Ġbinary ĠString `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( Bit Field . from ( byte ArrayOf ( 0 xaa . to Byte ())), ĠBit Field . from Bin (" 1 0 1 0 1 0 1 0 "), ĠBit Field . from Bin (" 1 0 1 0 1 0 1 0 "). to Binary String ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Bit Field . from ( byte ArrayOf ( 0 x 0 2 )), ĠBit Field . from Bin (" 1 0 "), ĠBit Field . from Bin (" 1 0 "). to Binary String ()) ĊĠĠĠ Ġ} Ċ } Ċ