package Ġorg . opp ia . android . util . parser . math Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . junit . Test Ċ import Ġjava . security . Message Digest Ċ Ċ /** ĠTests Ġfor Ġ[ Math Model ]. Ġ*/ Ċ // ĠFunction Name : Ġtest Ġnames Ġare Ġconvention ally Ġnamed Ġwith Ġunders cores . Ċ @ Suppress (" FunctionName ") Ċ class ĠMath Model Test Ġ{ ĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ same Model By Values _ returns Same Key With Same Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ ĠassertThat ( key 1 ). isEqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isEqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isEqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isEqualTo ( model 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ different Model By Lat ex _ returns Different Key With Different Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 3 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ Ġ// ĠSince Ġthe ĠLaTeX Ġdiffers , Ġnothing Ġshould Ġmatch . ĊĠĠĠ ĠassertThat ( key 1 ). isNot EqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isNot EqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isNot EqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isNot EqualTo ( model 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ different Model By Line Height _ returns Different Key With Different Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 0 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ Ġ// ĠSince Ġthe Ġline Ġheight Ġdiffers , Ġnothing Ġshould Ġmatch . ĊĠĠĠ ĠassertThat ( key 1 ). isNot EqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isNot EqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isNot EqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isNot EqualTo ( model 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ diff Model By Line Height _ within Two Decimal s _ returns Same Key With Same Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĊĠĠĠĠĠ ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 0 1 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ Ġ// ĠThe Ġline Ġheight s Ġare Ġclose Ġenough Ġthat Ġthey 're Ġconsidered Ġequal Ġfor Ġkey Ġpurposes Ġ( but Ġare ĊĠĠĠ Ġ// Ġstill Ġdifferent Ġmodels ). ĊĠĠĠ ĠassertThat ( key 1 ). isEqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isEqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isEqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isNot EqualTo ( model 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ diff Model By Line Height _ outside Two Decimal s _ returns Diff Key With Diff Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 6 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ Ġ// ĠSince Ġthe Ġline Ġheight Ġdiffers , Ġnothing Ġshould Ġmatch . ĊĠĠĠ ĠassertThat ( key 1 ). isNot EqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isNot EqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isNot EqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isNot EqualTo ( model 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest To Key Signature _ different Model By Inline Rendering _ returns Different Key With Different Digest () Ġ{ ĊĠĠĠ Ġval Ġmodel 1 Ġ= ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġtrue ) ĊĠĠĠ Ġval Ġmodel 2 Ġ= ĊĠĠĠĠĠ ĠMath Model ( raw Lat ex Ġ= Ġ"\\ frac { 2 }{ 6 }", Ġline Height Ġ= Ġ 2 1 . 5 f , Ġuse Inline Rendering Ġ= Ġfalse ) ĊĠĠĠ Ġval Ġdigest 1 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĠĠĠ Ġval Ġdigest 2 Ġ= ĠMessage Digest . getInstance (" SHA - 2 5 6 ") ĊĊĠĠĠ Ġval Ġkey 1 Ġ= Ġmodel 1 . to Key Signature () ĊĠĠĠ Ġval Ġkey 2 Ġ= Ġmodel 2 . to Key Signature () ĊĠĠĠ Ġkey 1 . update Disk CacheKey ( digest 1 ) ĊĠĠĠ Ġkey 2 . update Disk CacheKey ( digest 2 ) ĊĊĠĠĠ Ġ// ĠSince Ġthe Ġinline Ġrendering Ġsetting Ġdiffers , Ġnothing Ġshould Ġmatch . ĊĠĠĠ ĠassertThat ( key 1 ). isNot EqualTo ( key 2 ) ĊĠĠĠ ĠassertThat ( key 1 . hashCode ()). isNot EqualTo ( key 2 . hashCode ()) ĊĠĠĠ ĠassertThat ( digest 1 . digest ()). isNot EqualTo ( digest 2 . digest ()) ĊĠĠĠ ĠassertThat ( model 1 ). isNot EqualTo ( model 2 ) ĊĠ Ġ} Ċ } Ċ