@@ -0,0 +1,2405 @@
+package scratchlib.objects;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0A%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.assertArrayEquals;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport scratchlib.project.ScratchProject;%0Aimport scratchlib.project.ScratchVersion;%0Aimport scratchlib.reader.ScratchInputStream;%0Aimport scratchlib.writer.ScratchOutputStream;%0A%0A%0Apublic class ScratchObjectTest%0A%7B%0A    private static class NonReferenceType extends ScratchObject%0A    %7B%0A        public NonReferenceType(int classID)%0A        %7B%0A            super(classID);%0A        %7D%0A    %7D%0A%0A    private static class ReferenceType extends ScratchObject%0A            implements IScratchReferenceType%0A    %7B%0A        public ReferenceType(int classID)%0A        %7B%0A            super(classID);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void returnsClassID()%0A    %7B%0A        assertEquals(42, new NonReferenceType(42).getClassID());%0A    %7D%0A%0A    @Test%0A    public void createsSelfReferenceWhenReferenceType()%0A    %7B%0A        ScratchProject project = new ScratchProject(ScratchVersion.SCRATCH14);%0A%0A        ScratchReferenceTable table = new ScratchReferenceTable();%0A        assertEquals(0, table.size());%0A%0A        assertFalse(new NonReferenceType(42).createReferences(table, project));%0A        assertEquals(0, table.size());%0A%0A        assertTrue(new ReferenceType(42).createReferences(table, project));%0A        assertEquals(1, table.size());%0A    %7D%0A%0A    @Test%0A    public void writesNothingButClassID() throws IOException%0A    %7B%0A        ScratchProject project = new ScratchProject(ScratchVersion.SCRATCH14);%0A        ScratchReferenceTable ref = new ScratchReferenceTable();%0A%0A        ByteArrayOutputStream bout = new ByteArrayOutputStream();%0A        ScratchOutputStream sout = new ScratchOutputStream(bout);%0A%0A        new ReferenceType(42).writeTo(sout, ref, project);%0A%0A        assertArrayEquals(new byte%5B%5D %7B 42 %7D, bout.toByteArray());%0A    %7D%0A%0A    @Test(expected = IOException.class)%0A    public void readThrowsForWrongClassID() throws IOException%0A    %7B%0A        ScratchProject project = new ScratchProject(ScratchVersion.SCRATCH14);%0A        ScratchInputStream in = new ScratchInputStream(%0A                new ByteArrayInputStream(new byte%5B0%5D));%0A%0A        new ReferenceType(42).readFrom(37, in, project);%0A    %7D%0A%7D%0A

Add unit tests for ScratchObject