blob: c6d27ac90b4d521780c912286c8e98b0a064275b [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package io.v.v23.vdl;
import io.v.v23.vom.testdata.Constants;
import io.v.v23.vom.testdata.TestCase;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* Tests that the VDL types are correctly parceled.
*/
public class SerializableTest extends junit.framework.TestCase {
public void testSerializable() throws IOException, ClassNotFoundException {
for (TestCase test : Constants.TESTS) {
Object value = test.getValue().getElem();
if (!(value instanceof VdlValue)) continue;
// Write
ByteArrayOutputStream data = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(data);
out.writeObject(value);
out.close();
// Read
ObjectInputStream in =
new ObjectInputStream(new ByteArrayInputStream(data.toByteArray()));
// Verify
Object copy = in.readObject();
assertEquals(value, copy);
assertEquals(value.hashCode(), copy.hashCode());
}
}
}