summaryrefslogtreecommitdiff
path: root/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/typedarray/ArrayBufferInputStreamTest.scala
blob: 7c49d0cbe88e1b200a1546935e33a489066f3f8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*                     __                                               *\
**     ________ ___   / /  ___      __ ____  Scala.js Test Suite        **
**    / __/ __// _ | / /  / _ | __ / // __/  (c) 2013, LAMP/EPFL        **
**  __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \    http://scala-js.org/       **
** /____/\___/_/ |_/____/_/ | |__/ /____/                               **
**                          |/____/                                     **
\*                                                                      */
package scala.scalajs.testsuite.typedarray

import scala.scalajs.testsuite.javalib.CommonStreamsTests

import scala.scalajs.js.typedarray._

import org.scalajs.jasminetest.JasmineTest

/** Tests for our implementation of java.io._ stream classes */
object ArrayBufferInputStreamTest extends JasmineTest with CommonStreamsTests {

  when("typedarray").
  describe("scala.scalajs.js.typedarray.ArrayBufferInputStream") {
    byteArrayInputStreamLikeTests(seq => new ArrayBufferInputStream(
        new Int8Array(seq).buffer))
  }

  when("typedarray").
  describe("scala.scalajs.js.typedarray.ArrayBufferInputStream - with offset") {
    byteArrayInputStreamLikeTests { seq =>
      val off = 100
      val data = new Int8Array(seq.size + off)
      data.set(seq, off)

      new ArrayBufferInputStream(data.buffer, off, seq.size)
    }
  }

}