GZIPIOStreamTest.scala | GZIPIOStreamTest.scala | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
after { | after { | |||
} | } | |||
behavior of "GZIPOutputStream and GZIPInputStream" | behavior of "GZIPOutputStream and GZIPInputStream" | |||
it can "deflate and infate data." in { | it can "deflate and infate data." in { | |||
val comment = "hi" | val comment = "hi" | |||
val name = "/tmp/foo" | val name = "/tmp/foo" | |||
val time = System.currentTimeMillis() / 1000 | ||||
val content = "hello".getBytes | val content = "hello".getBytes | |||
val baos = new ByteArrayOutputStream | val baos = new ByteArrayOutputStream | |||
val gos = new GZIPOutputStream(baos) | val gos = new GZIPOutputStream(baos) | |||
gos.setComment(comment) | gos.setComment(comment) | |||
gos.setName(name) | gos.setName(name) | |||
gos.setModifiedTime(time) | ||||
gos.write(content) | gos.write(content) | |||
gos.close | gos.close | |||
val bais = new ByteArrayInputStream(baos.toByteArray) | val bais = new ByteArrayInputStream(baos.toByteArray) | |||
val gis = new GZIPInputStream(bais) | val gis = new GZIPInputStream(bais) | |||
val buf = new Array[Byte](1024) | val buf = new Array[Byte](1024) | |||
val i = gis.read(buf) | val i = gis.read(buf) | |||
content.length should equal(i) | content.length should equal(i) | |||
(0 until i) foreach { i => | (0 until i) foreach { i => | |||
content(i).asInstanceOf[Byte] should equal(buf(i).asInstanceOf[Byte]) | content(i).asInstanceOf[Byte] should equal(buf(i).asInstanceOf[Byte]) | |||
} | } | |||
comment should equal(gis.getComment) | comment should equal(gis.getComment) | |||
name should equal(gis.getName) | name should equal(gis.getName) | |||
time should equal(gis.getModifiedTime) | ||||
val crc32 = new CRC32 | val crc32 = new CRC32 | |||
crc32.update(content, 0, content.length) | crc32.update(content, 0, content.length) | |||
crc32.getValue should equal(gis.getCRC.asInstanceOf[Long]) | crc32.getValue should equal(gis.getCRC.asInstanceOf[Long]) | |||
} | } | |||
behavior of "GZIPOutputStream" | behavior of "GZIPOutputStream" | |||
// https://github.com/ymnk/jzlib/issues/9 | // https://github.com/ymnk/jzlib/issues/9 | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 3 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |