|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 6 | + * and is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 | + */ |
| 8 | +package tech.pantheon.triemap; |
| 9 | + |
| 10 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 11 | +import static org.junit.jupiter.api.Assertions.assertSame; |
| 12 | + |
| 13 | +import java.io.ByteArrayInputStream; |
| 14 | +import java.io.ByteArrayOutputStream; |
| 15 | +import java.io.ObjectInputStream; |
| 16 | +import java.io.ObjectOutputStream; |
| 17 | +import java.util.HexFormat; |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | + |
| 20 | +class EquivalenceTest { |
| 21 | + @Test |
| 22 | + void readResolveWorks() throws Exception { |
| 23 | + final var baos = new ByteArrayOutputStream(); |
| 24 | + try (var oos = new ObjectOutputStream(baos)) { |
| 25 | + oos.writeObject(Equivalence.Equals.INSTANCE); |
| 26 | + } |
| 27 | + |
| 28 | + final var bytes = baos.toByteArray(); |
| 29 | + assertEquals(""" |
| 30 | + aced000573720028746563682e70616e7468656f6e2e747269656d61702e4571756976616c656e636524457175616c7300000000000\ |
| 31 | + 0000102000078720021746563682e70616e7468656f6e2e747269656d61702e4571756976616c656e63650000000000000001020000\ |
| 32 | + 7870""", HexFormat.of().formatHex(bytes)); |
| 33 | + |
| 34 | + try (var ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) { |
| 35 | + assertSame(Equivalence.Equals.INSTANCE, ois.readObject()); |
| 36 | + } |
| 37 | + } |
| 38 | +} |
0 commit comments