(t *testing.T)
| 8 | import "testing" |
| 9 | |
| 10 | func TestReverseBits(t *testing.T) { |
| 11 | var tests = []struct { |
| 12 | name string |
| 13 | number uint |
| 14 | result uint |
| 15 | }{ |
| 16 | {"43261596 (00000010100101000001111010011100) to 964176192 (00111001011110000010100101000000)", 43261596, 964176192}, |
| 17 | {"3758096384 (11100000000000000000000000000000) to 7 (00000000000000000000000000000111)", 3758096384, 7}, |
| 18 | {"7 (00000000000000000000000000000111) to 3758096384 (11100000000000000000000000000000)", 7, 3758096384}, |
| 19 | {"2684354560 (10100000000000000000000000000000) to 5 (00000000000000000000000000000101)", 2684354560, 5}, |
| 20 | {"2684354561 (10100000000000000000000000000001) to 5 (10000000000000000000000000000101)", 2684354561, 2147483653}, |
| 21 | } |
| 22 | for _, tv := range tests { |
| 23 | t.Run(tv.name, func(t *testing.T) { |
| 24 | result := ReverseBits(tv.number) |
| 25 | t.Log(result) |
| 26 | if result != tv.result { |
| 27 | t.Errorf("Wrong result! Expected:%d, returned:%d ", tv.result, result) |
| 28 | } |
| 29 | }) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func BenchmarkReverseBits(b *testing.B) { |
| 34 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected