package Ġtests Ċ Ċ import Ġio . fluid sonic . locale .* Ċ import Ġkotlin . test .* ĊĊ Ċ class ĠLocale Tests Ġ{ ĊĊ ĉ @ Test Ċ ĉ fun Ġtest Equals And HashCode () Ġ{ Ċĉ ĉ assertEquals ( expected Ġ= ĠLocale . for Language Tag (" en - US "), Ġactual Ġ= ĠLocale . for Language Tag (" en - US ")) Ċĉ ĉ assertEquals ( expected Ġ= ĠLocale . for Language Tag (" en - US "). hashCode (), Ġactual Ġ= ĠLocale . for Language Tag (" en - US "). hashCode ()) ĊĊĉ ĉ assertEquals ( expected Ġ= ĠLocale . for Language Tag (" en - US - variant "), Ġactual Ġ= ĠLocale . for Language Tag (" en - US - VARIANT ")) Ċĉ ĉ assertEquals ( expected Ġ= ĠLocale . for Language Tag (" en - US - variant "). hashCode (), Ġactual Ġ= ĠLocale . for Language Tag (" en - US - VARIANT "). hashCode ()) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest For Language () Ġ{ Ċĉ ĉ assertEquals ( expected Ġ= Ġ" und ", Ġactual Ġ= ĠLocale . for Language ( language Ġ= Ġnull ). toString ()) Ċĉ ĉ assertEquals ( expected Ġ= Ġ" und ", Ġactual Ġ= ĠLocale . for Language ( language Ġ= Ġ""). toString ()) Ċĉ ĉ assertEquals ( expected Ġ= Ġ" en ", Ġactual Ġ= ĠLocale . for Language ( language Ġ= Ġ" EN "). toString ()) Ċĉ ĉ assertEquals ( expected Ġ= Ġ" en - US ", Ġactual Ġ= ĠLocale . for Language ( language Ġ= Ġ" EN ", Ġregion Ġ= Ġ" us "). toString ()) Ċĉ ĉ assertEquals ( expected Ġ= Ġ" zh - H ant - CN ", Ġactual Ġ= ĠLocale . for Language ( language Ġ= Ġ" ZH ", Ġscript Ġ= Ġ" h ANT ", Ġregion Ġ= Ġ" cn "). toString ()) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ expected Ġ= Ġ" zh - H ant - CN - VARIANT 1 - VARIANT 2 ", Ċĉĉ ĉ actual Ġ= ĠLocale . for Language ( language Ġ= Ġ" ZH ", Ġscript Ġ= Ġ" h ANT ", Ġregion Ġ= Ġ" cn ", Ġvariants Ġ= ĠlistOf (" VARIANT 1 ", Ġ" VARIANT 2 ")). toString () Ċĉ ĉ ) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest For Language OrFail () Ġ{ Ċĉ ĉ assertEquals ( Ċĉĉ ĉ expected Ġ= Ġ" Invalid Ġlanguage : Ġx ", Ċĉĉ ĉ actual Ġ= Ġassert Fails Ġ{ ĠLocale . for Language ( language Ġ= Ġ" x ") Ġ}. message Ċĉ ĉ ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ expected Ġ= Ġ" Invalid Ġregion : Ġx ", Ċĉĉ ĉ actual Ġ= Ġassert Fails Ġ{ ĠLocale . for Language ( language Ġ= Ġ" en ", Ġregion Ġ= Ġ" x ") Ġ}. message Ċĉ ĉ ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ expected Ġ= Ġ" Invalid Ġscript : Ġx ", Ċĉĉ ĉ actual Ġ= Ġassert Fails Ġ{ ĠLocale . for Language ( language Ġ= Ġ" en ", Ġscript Ġ= Ġ" x ", Ġregion Ġ= Ġ" US ") Ġ}. message Ċĉ ĉ ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ expected Ġ= Ġ" Invalid Ġvariant : Ġvar ", Ċĉĉ ĉ actual Ġ= Ġassert Fails Ġ{ ĠLocale . for Language ( language Ġ= Ġ" zh ", Ġscript Ġ= Ġ" H ant ", Ġregion Ġ= Ġ" CN ", Ġvariants Ġ= ĠlistOf (" var ")) Ġ}. message Ċĉ ĉ ) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest For Language OrNull () Ġ{ Ċĉ ĉ assertNull ( Locale . for Language OrNull ( language Ġ= Ġ" x ")) Ċĉ ĉ assertNull ( Locale . for Language OrNull ( language Ġ= Ġ" en ", Ġregion Ġ= Ġ" x ")) Ċĉ ĉ assertNull ( Locale . for Language OrNull ( language Ġ= Ġ" en ", Ġscript Ġ= Ġ" x ", Ġregion Ġ= Ġ" US ")) Ċĉ ĉ assertNull ( Locale . for Language OrNull ( language Ġ= Ġ" zh ", Ġscript Ġ= Ġ" H ant ", Ġregion Ġ= Ġ" CN ", Ġvariants Ġ= ĠlistOf (" var "))) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest For Language Tag () Ġ{ Ċĉ ĉ assertEquals ( expected Ġ= Ġ" en - US ", Ġactual Ġ= ĠLocale . for Language Tag ( Language Tag . parse (" en - US ")). toString ()) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest For Language Tag String () Ġ{ Ċĉ ĉ assertEquals ( expected Ġ= Ġ" en - US ", Ġactual Ġ= ĠLocale . for Language Tag (" en - US "). toString ()) Ċĉ ĉ assertEquals ( expected Ġ= Ġ" en - US ", Ġactual Ġ= ĠLocale . for Language Tag (" en - us "). toString ()) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest Properties () Ġ{ Ċĉ ĉ val Ġtag Ġ= ĠLanguage Tag . parse (" zh - H ant - CN - Variant ") Ċĉ ĉ val Ġlocale Ġ= ĠLocale . for Language Tag ( tag ) ĊĊĉ ĉ assertEquals ( expected Ġ= Ġtag . language , Ġactual Ġ= Ġlocale . language ) Ċĉ ĉ assertEquals ( expected Ġ= Ġtag . region , Ġactual Ġ= Ġlocale . region ) Ċĉ ĉ assertEquals ( expected Ġ= Ġtag . script , Ġactual Ġ= Ġlocale . script ) Ċĉ ĉ assertEquals ( expected Ġ= Ġtag . variants , Ġactual Ġ= Ġlocale . variants ) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest To Language Tag () Ġ{ Ċĉ ĉ val Ġtag Ġ= ĠLanguage Tag . parse (" zh - H ant - CN - Variant ") Ċĉ ĉ val Ġlocale Ġ= ĠLocale . for Language Tag ( tag ) ĊĊĉ ĉ assertEquals ( expected Ġ= Ġtag , Ġactual Ġ= Ġlocale . to Language Tag ()) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest Root () Ġ{ Ċĉ ĉ val Ġlocale Ġ= ĠLocale . root ĊĊĉ ĉ assertNull ( locale . language ) Ċĉ ĉ assertNull ( locale . region ) Ċĉ ĉ assertNull ( locale . script ) Ċĉ ĉ assertEquals ( expected Ġ= Ġempty List (), Ġactual Ġ= Ġlocale . variants ) Ċ ĉ } ĊĊĊ ĉ @ Test Ċ ĉ fun Ġtest ToString () Ġ{ Ċĉ ĉ assertEquals ( expected Ġ= Ġ" zh - H ant - CN - Variant ", Ġactual Ġ= ĠLocale . for Language Tag (" ZH - H ANT - CN - Variant "). toString ()) Ċ ĉ } Ċ } Ċ