@Test
    public void test_toByte() {
        ProtocolSwitch protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(0);
        Assert.assertEquals(1, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(1);
        Assert.assertEquals(2, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(2);
        Assert.assertEquals(4, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(3);
        Assert.assertEquals(8, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(0);
        protocolSwitch.turnOn(1);
        Assert.assertEquals(3, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        protocolSwitch.turnOn(6);
        Assert.assertEquals(64, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        for (int i = 0; i < 7; ++i) {
            protocolSwitch.turnOn(i);
        }
        Assert.assertEquals(127, protocolSwitch.toByte());

        protocolSwitch = new ProtocolSwitch();
        for (int i = 0; i < 8; ++i) {
            protocolSwitch.turnOn(i);
        }
        try {
            protocolSwitch.toByte();
            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