@Test
    public void test_bitSetToByte() {
        BitSet bs = new BitSet();

        bs.set(0);
        Assert.assertEquals(1, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(1);
        Assert.assertEquals(2, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(2);
        Assert.assertEquals(4, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(3);
        Assert.assertEquals(8, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(0);
        bs.set(1);
        Assert.assertEquals(3, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(2);
        bs.set(3);
        Assert.assertEquals(12, ProtocolSwitch.toByte(bs));

        bs.clear();
        bs.set(6);
        Assert.assertEquals(64, ProtocolSwitch.toByte(bs));

        bs.clear();
        for (int i = 0; i <= 6; ++i) {
            bs.set(i);
        }
        Assert.assertEquals(127, ProtocolSwitch.toByte(bs));

        bs.clear();
        for (int i = 0; i <= 7; ++i) {
            bs.set(i);
        }
        try {
            ProtocolSwitch.toByte(bs);
            Assert.fail("Should not reach here!");
        } catch (IllegalArgumentException e) {
        }
    }
@author tsui
@version $Id: ProtocolSwitchStatusTest.java, v 0.1 2017-10-09 20:23 tsui Exp $
src/test/java/com/alipay/remoting/inner/utiltest/ProtocolSwitchTest.java