Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/5400#discussion_r43674059
--- Diff:
core/src/test/scala/org/apache/spark/util/io/ByteArrayChunkOutputStreamSuite.scala
---
@@ -106,4 +105,30 @@ class ByteArrayChunkOutputStreamSuite extends
SparkFunSuite {
assert(arrays(1).toSeq === ref.slice(10, 20))
assert(arrays(2).toSeq === ref.slice(20, 30))
}
+
+ test("slice") {
+ val ref = new Array[Byte](30)
+ Random.nextBytes(ref)
+ val o = new ByteArrayChunkOutputStream(5)
+ o.write(ref)
+
+ for {
+ start <- (0 until 30)
+ end <- (start to 30)
+ } {
+ withClue(s"start = $start; end = $end") {
+ try {
+ assert(o.slice(start, end).toSeq === ref.slice(start, end))
+ } catch {
+ case ex => fail(ex)
+ }
+ }
+ }
+
+ // errors on bad bounds
+ intercept[IllegalArgumentException]{o.slice(31, 31)}
--- End diff --
nit: missing spaces (I think the new style checker will complain about
this).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]