package Ġcom . sk sam uel . kot est . matchers . channels Ċ Ċ import Ġio . kot est . assertions . should Fail Ċ import Ġio . kot est . core . spec . style . String Spec Ċ import Ġio . kot est . matchers . channels . shouldBe Closed Ċ import Ġio . kot est . matchers . channels . shouldBe Empty Ċ import Ġio . kot est . matchers . channels . should Have Size Ċ import Ġio . kot est . matchers . channels . should Receive At Least Ċ import Ġio . kot est . matchers . channels . should Receive At Most Ċ import Ġio . kot est . matchers . ints . shouldBe Exactly Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠChannel Test Ġ: ĠString Spec () Ġ{ ĊĠ Ġinit Ġ{ ĊĠĠĠ Ġ" shouldBe Closed Ġshould Ġnot Ġfail Ġon Ġclosed Ġchannels " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġchannel . shouldBe Closed () ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" shouldBe Closed Ġshould Ġfail Ġon Ġopen Ġchannels " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġshould Fail Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . shouldBe Closed () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" shouldBe Empty Ġshould Ġnot Ġfail Ġon Ġempty Ġchannels " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġchannel . shouldBe Empty () ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" shouldBe Empty Ġshould Ġnot Ġfail Ġon Ġchannels Ġthat Ġhave Ġreceived Ġall Ġelements " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . send ( 1 ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . receive () ĠshouldBe Exactly Ġ 1 ĊĠĠĠĠĠ Ġchannel . shouldBe Empty () ĊĠĠĠ Ġ} ĊĠĠĠĠ Ġ" shouldBe Empty Ġshould Ġfail Ġon Ġnon - empty Ġchannels " Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel ( 1 ) ĊĠĠĠĠĠĠĠ Ġchannel . send ( 1 ) ĊĠĠĠĠĠĠĠ Ġshould Fail Ġ{ ĊĠĠĠĠĠĠĠĠĠĠ Ġchannel . shouldBe Empty () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . receive () ĠshouldBe Ġ 1 ĊĠĠĠĠ Ġ} ĊĠĠĠ Ġ"! should Have Size Ġshould Ġnot Ġfail Ġwhen Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 0 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . should Have Size ( 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Have Size Ġshould Ġfail Ġwhen Ġgreater Ġthan Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 2 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġshould Fail Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . should Have Size ( 1 0 ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġrepeat ( 2 ) Ġ{ Ġchannel . receive () Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Receive At Least Ġshould Ġnot Ġfail Ġwhen Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 0 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . should Receive At Least ( 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Receive At Least Ġshould Ġnot Ġfail Ġwhen Ġgreater Ġthan Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 2 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . should Receive At Least ( 1 0 ) ĊĠĠĠĠĠ Ġrepeat ( 2 ) Ġ{ Ġchannel . receive () Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Receive At Most Ġshould Ġnot Ġfail Ġwhen Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 0 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . should Receive At Most ( 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Receive At Most Ġshould Ġnot Ġfail Ġwhen Ġless Ġthan Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 9 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . should Receive At Most ( 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ" should Receive At Most Ġshould Ġfail Ġwhen Ġmore Ġthan Ġn Ġelements Ġare Ġsent " Ġ{ ĊĠĠĠĠĠ Ġval Ġchannel : ĠChannel < Int > Ġ= ĠChannel () ĊĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepeat ( 1 1 ) Ġ{ Ġchannel . send ( 1 ) Ġ} ĊĠĠĠĠĠĠĠ Ġchannel . close () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġshould Fail Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . should Receive At Most ( 1 0 ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġchannel . receive () ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ