<s> import unittest <EOL> from random import randrange <EOL> from migen import * <EOL> from migen . genlib . sort import * <EOL> from migen . test . support import SimCase <EOL> class BitonicCase ( SimCase , unittest . TestCase ) : <EOL> class TestBench ( Module ) : <EOL> def __init__ ( self ) : <EOL> self . submodules . dut = BitonicSort ( <NUM_LIT:8> , <NUM_LIT:4> , ascending = True ) <EOL> def test_sizes ( self ) : <EOL> self . assertEqual ( len ( self . tb . dut . i ) , <NUM_LIT:8> ) <EOL> self . assertEqual ( len ( self . tb . dut . o ) , <NUM_LIT:8> ) <EOL> for i in range ( <NUM_LIT:8> ) : <EOL> self . assertEqual ( len ( self . tb . dut . i [ i ] ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( len ( self . tb . dut . o [ i ] ) , <NUM_LIT:4> ) <EOL> def test_sort ( self ) : <EOL> def gen ( ) : <EOL> for repeat in range ( <NUM_LIT:20> ) : <EOL> for i in self . tb . dut . i : <EOL> yield i . eq ( randrange ( <NUM_LIT:1> << len ( i ) ) ) <EOL> yield <EOL> self . assertEqual ( sorted ( ( yield self . tb . dut . i ) ) , <EOL> ( yield self . tb . dut . o ) ) <EOL> self . run_with ( gen ( ) ) </s>
