ZxEmlSnapshotFormat extends ZXPParser { public byte[] save() throws IOException { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final JBBPBitOutputStream bout = new JBBPBitOutputStream(buffer); this.write(bout); bout.close(); return buffer.toByteArray(); } ZxEmlSnapshotFormat();  ZxEmlSnapshotFormat(final byte[] data); void setModulePorts(final int cpuIndex, final int port7FFD, final int r0, final int r1, final int r2, final int r3); byte[] getModulePorts(final int cpuIndex); byte[] save(); static final int MAGIC; static final int INDEX_CPU0; static final int INDEX_CPU1; static final int INDEX_CPU2; static final int INDEX_CPU3; }
@Test public void testSaveLoad_Snapshot() throws Exception { final byte [] array = loadResource("fh.zxp"); final ZxEmlSnapshotFormat data = new ZxEmlSnapshotFormat(); data.read(new JBBPBitInputStream(new ByteArrayInputStream(array.clone()))); assertArrayEquals(array, data.save()); }