Skip to content

Commit

Permalink
Get the tests working.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Oct 17, 2024
1 parent 685e9ff commit 681903d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void testUniqueIdentifier() {
UniqueIdentifierSerializer ser = new UniqueIdentifierSerializer();
kryo.register(UniqueIdentifier.class, ser);

UniqueIdentifier.GENERATOR.stringDeserialize("FFFFFFFFFFFFFFFF$EEEEEEEEEEEEEEEE");
UniqueIdentifier.GENERATOR.stringDeserialize("FFFFFFFF$FFFFFFFF$EEEEEEEE$EEEEEEEE");
UniqueIdentifier data = UniqueIdentifier.next();

ByteArrayOutputStream baos = new ByteArrayOutputStream(32);
Expand All @@ -52,7 +52,7 @@ public void testUniqueIdentifierGenerator() {
kryo.register(UniqueIdentifier.class, ser);
kryo.register(UniqueIdentifier.Generator.class, ser);

UniqueIdentifier.GENERATOR.stringDeserialize("FFFFFFFFFFFFFFFF$EEEEEEEEEEEEEEEE");
UniqueIdentifier.GENERATOR.stringDeserialize("FFFFFFFF$FFFFFFFF$EEEEEEEE$EEEEEEEE");
UniqueIdentifier.Generator data = UniqueIdentifier.GENERATOR;

ByteArrayOutputStream baos = new ByteArrayOutputStream(32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.github.tommyettinger.cringe.PointSequence.*;
import com.github.tommyettinger.cringe.Vector5;
import com.github.tommyettinger.cringe.Vector6;
import com.github.tommyettinger.kryo.cringe.PointSequenceSerializers.*;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -256,4 +258,38 @@ public void testR6() {
Assert.assertEquals(data.z, data2.z, Float.MIN_NORMAL);
}
}

@Test
public void testVector5() {
Kryo kryo = new Kryo();
kryo.register(Vector5.class, new Vector5Serializer());

Vector5 data = new Vector5(0.1f, 0.2f, 0.3f, 0.4f, 0.5f);

ByteArrayOutputStream baos = new ByteArrayOutputStream(32);
Output output = new Output(baos);
kryo.writeObject(output, data);
byte[] bytes = output.toBytes();
try (Input input = new Input(bytes)) {
Vector5 data2 = kryo.readObject(input, Vector5.class);
Assert.assertEquals(data, data2);
}
}

@Test
public void testVector6() {
Kryo kryo = new Kryo();
kryo.register(Vector6.class, new Vector6Serializer());

Vector6 data = new Vector6(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f);

ByteArrayOutputStream baos = new ByteArrayOutputStream(32);
Output output = new Output(baos);
kryo.writeObject(output, data);
byte[] bytes = output.toBytes();
try (Input input = new Input(bytes)) {
Vector6 data2 = kryo.readObject(input, Vector6.class);
Assert.assertEquals(data, data2);
}
}
}

0 comments on commit 681903d

Please sign in to comment.