package Ġcom . j esse cor bet t . disk ord . util Ċ Ċ import Ġassert k . all Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġassert k . assertions . is Failure Ċ import Ġassert k . assertions . isInstanceOf Ċ import Ġassert k . throw n Error Ċ import Ġkotlin . test . Test Ċ Ċ class ĠColors Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġconvert Ġrgb Ġfloats Ġto Ġcolor `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 1 F , Ġ 0 F , Ġ 0 F )). isEqualTo ( 0 xFF 0 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 F , Ġ 1 F , Ġ 0 F )). isEqualTo ( 0 x 0 0 FF 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 F , Ġ 0 F , Ġ 1 F )). isEqualTo ( 0 x 0 0 0 0 FF ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 F , Ġ 0 F , Ġ 0 F )). isEqualTo ( 0 x 0 0 0 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġthrow Ġexception Ġfor Ġout - of - range Ġrgb Ġfloats `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb (- 1 F , Ġ 0 F , Ġ 0 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 2 F , Ġ 0 F , Ġ 0 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 F , Ġ- 1 F , Ġ 0 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 F , Ġ 2 F , Ġ 0 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 F , Ġ 0 F , Ġ- 1 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 F , Ġ 0 F , Ġ 2 F ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġconvert Ġrgb Ġintegers Ġto Ġcolor `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 2 5 5 , Ġ 0 , Ġ 0 )). isEqualTo ( 0 xFF 0 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 , Ġ 2 5 5 , Ġ 0 )). isEqualTo ( 0 x 0 0 FF 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 , Ġ 0 , Ġ 2 5 5 )). isEqualTo ( 0 x 0 0 0 0 FF ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . rgb ( 0 , Ġ 0 , Ġ 0 )). isEqualTo ( 0 x 0 0 0 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġthrow Ġexception Ġfor Ġout - of - range Ġrgb Ġintegers `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 2 5 6 , Ġ 0 , Ġ 0 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb (- 1 , Ġ 0 , Ġ 0 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 , Ġ 2 5 6 , Ġ 0 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 , Ġ- 1 , Ġ 0 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 , Ġ 0 , Ġ 2 5 6 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . rgb ( 0 , Ġ 0 , Ġ- 1 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġconvert Ġhex Ġinteger Ġto Ġcolor `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ( 0 xFF 0 0 0 0 )). isEqualTo ( 0 xFF 0 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ( 0 x 0 0 FF 0 0 )). isEqualTo ( 0 x 0 0 FF 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ( 0 x 0 0 0 0 FF )). isEqualTo ( 0 x 0 0 0 0 FF ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ( 0 x 0 0 0 0 0 0 )). isEqualTo ( 0 x 0 0 0 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġconvert Ġhex Ġstring Ġto Ġcolor `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ("# FF 0 0 0 0 ")). isEqualTo ( 0 xFF 0 0 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ("# 0 0 ff 0 0 ")). isEqualTo ( 0 x 0 0 FF 0 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ("# 0 0 0 0 Ff ")). isEqualTo ( 0 x 0 0 0 0 FF ) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . hex ("# 0 0 0 0 0 0 ")). isEqualTo ( 0 x 0 0 0 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġthrow Ġan Ġexception Ġfor Ġinvalid Ġhex Ġstrings `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ("# F 0 0 ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex (" FF 0 0 0 0 ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex (" red ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ("# c chars ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ("# ele ven ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ("# - 1 0 1 0 1 ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex (" something Ġ# FFF 0 0 0 ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ("# F 0 0 0 0 0 ĠBAR ") Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġthrow Ġexception Ġfor Ġout - of - range Ġhex Ġvalues `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex ( 0 xF 0 0 0 0 0 0 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠĠĠĠĠ ĠassertThat Ġ{ ĠColors . hex (- 0 x 1 ) Ġ}. is Failure (). isInstanceOf ( IllegalArgumentException :: class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġconvert Ġcolor Ġto Ġrgb Ġtriple `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . to RGB ( 0 xFF 0 0 0 0 )). isEqualTo ( Triple ( 2 5 5 , Ġ 0 , Ġ 0 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . to RGB ( 0 x 0 0 FF 0 0 )). isEqualTo ( Triple ( 0 , Ġ 2 5 5 , Ġ 0 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . to RGB ( 0 x 0 0 0 0 FF )). isEqualTo ( Triple ( 0 , Ġ 0 , Ġ 2 5 5 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( Colors . to RGB ( 0 x 0 0 0 0 0 0 )). isEqualTo ( Triple ( 0 , Ġ 0 , Ġ 0 )) ĊĠĠĠ Ġ} Ċ } Ċ