@Test public void writeData_throwsIfArrayTooLarge() throws IOException { Tm1637 tm1637 = new Tm1637(mDevice); mExpectedException.expect(IllegalArgumentException.class); tm1637.writeData(new byte[Tm1637.MAX_DATA_LENGTH + 1]); }
public void writeData(byte[] data) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (data.length > MAX_DATA_LENGTH) { throw new IllegalArgumentException("data size should be less than " + MAX_DATA_LENGTH); } mDevice.writeRegBuffer(TM1637_REG, data, data.length); }
Tm1637 implements Closeable { public void writeData(byte[] data) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (data.length > MAX_DATA_LENGTH) { throw new IllegalArgumentException("data size should be less than " + MAX_DATA_LENGTH); } mDevice.writeRegBuffer(TM1637_REG, data, data.length); } }
Tm1637 implements Closeable { public void writeData(byte[] data) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (data.length > MAX_DATA_LENGTH) { throw new IllegalArgumentException("data size should be less than " + MAX_DATA_LENGTH); } mDevice.writeRegBuffer(TM1637_REG, data, data.length); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); }
Tm1637 implements Closeable { public void writeData(byte[] data) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (data.length > MAX_DATA_LENGTH) { throw new IllegalArgumentException("data size should be less than " + MAX_DATA_LENGTH); } mDevice.writeRegBuffer(TM1637_REG, data, data.length); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); @Override void close(); void setBrightness(int value); void setBrightness(float value); void writeData(byte[] data); }
Tm1637 implements Closeable { public void writeData(byte[] data) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (data.length > MAX_DATA_LENGTH) { throw new IllegalArgumentException("data size should be less than " + MAX_DATA_LENGTH); } mDevice.writeRegBuffer(TM1637_REG, data, data.length); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); @Override void close(); void setBrightness(int value); void setBrightness(float value); void writeData(byte[] data); static final int MAX_BRIGHTNESS; static final int MAX_DATA_LENGTH; }