Skip to content

Commit

Permalink
add serde test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-williams committed Jun 20, 2017
1 parent 15b4a4e commit 90a2603
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/scala/org/hammerlab/paths/PathTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hammerlab.paths

import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream }
import java.nio.file.Files
import java.nio.file.Files.{ createDirectory, createTempDirectory }

Expand Down Expand Up @@ -105,6 +106,22 @@ class PathTest
path.lines.toSeq should be(lines)
}

test("serialize path") {
val path = Path("abc/def")
val baos = new ByteArrayOutputStream()
val oos = new ObjectOutputStream(baos)

oos.writeObject(path)

val bytes = baos.toByteArray
bytes.length should be(94)

val bais = new ByteArrayInputStream(bytes)
val ois = new ObjectInputStream(bais)

ois.readObject().asInstanceOf[Path] should be(path)
}

val dirs = ArrayBuffer[Path]()

def tmpDir(prefix: String = this.getClass.getSimpleName): Path = {
Expand Down

0 comments on commit 90a2603

Please sign in to comment.