package a2geek.apple2.image.encoder.encode; import junit.framework.TestCase; /** * Contains helper methods that can be imported into any of the encoder tests. * * @author a2geek@users.noreply.github.com */ public abstract class EncoderTestCase extends TestCase { /** * Convert a hex string into an array of bytes. * String is in the format "112233" which is decoded as the array * of bytes 0x11, 0x22, 0x33. */ public byte[] toBytes(String hexString) { if (hexString == null || hexString.length() % 2 == 1) { throw new NumberFormatException("String must be an even length and not null"); } byte[] data = new byte[hexString.length() / 2]; for (int i=0; i 0) data.append(repeatedBytes); return data.toString(); } }