package Ġcom . mo yi . li u . audio feedback . adapter . transformer Ċ Ċ import Ġcom . google . common . truth . Truth Ċ import Ġcom . mo yi . li u . audio feedback . domain . model . Boundary Ċ import Ġorg . junit . Test Ċ import Ġkotlin . math . pow Ċ Ċ class ĠPlay Rate Transformer Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Sensor Data Value Is Small er Than Min _ volume ShouldBe Min () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġboundary Ġ= ĠBound ary ( 1 f , Ġ 3 f ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġ 0 . 5 f ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġvalue . transform To Play Rate Audio Context ( boundary ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . volume ). isEqualTo ( MIN _ VOLUME ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Sensor Data Value Is EqualTo Max _ play Rate ShouldBe Max _ volume ShouldBe Max () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġboundary Ġ= ĠBound ary ( 1 f , Ġ 3 f ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġ 3 f ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġvalue . transform To Play Rate Audio Context ( boundary ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . volume ). isEqualTo ( MAX _ VOLUME ) ĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . play Rate ). isEqualTo ( MAX _ PLAY _ RATE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Sensor Data Value Is L arger Than Max _ play Rate ShouldBe Max _ volume ShouldBe Max () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġboundary Ġ= ĠBound ary ( 1 f , Ġ 3 f ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġ 3 . 1 f ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġvalue . transform To Play Rate Audio Context ( boundary ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . volume ). isEqualTo ( MAX _ VOLUME ) ĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . play Rate ). isEqualTo ( MAX _ PLAY _ RATE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Sensor Data Value IsIn Range _ play Rate ShouldBe Squared Pro portional _ volume ShouldBe Max () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġboundary Ġ= ĠBound ary ( 3 f , Ġ 6 f ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġ 4 f ĊĠĠĠĠĠĠĠ Ġval Ġ( min , Ġmax ) Ġ= Ġboundary ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠNORMAL _ PLAY _ RATE Ġ+ Ġ(( value Ġ- Ġmin ) Ġ/ Ġ( max Ġ- Ġmin )). pow ( 2 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġvalue . transform To Play Rate Audio Context ( boundary ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . volume ). isEqualTo ( MAX _ VOLUME ) ĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( result . play Rate ). isEqualTo ( expected ) ĊĠĠĠ Ġ} Ċ }