yzt
2023-05-26 2f70f6727314edd84d8ec2bfe3ce832803f1ea77
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
37
38
39
40
41
42
43
44
45
46
47
48
import { arraySlice } from "../../Source/Cesium.js";
import { FeatureDetection } from "../../Source/Cesium.js";
 
describe("Core/arraySlice", function () {
  var array = [1, 2, 3, 4, 5];
 
  it("slices entire array", function () {
    var slice = arraySlice(array);
    expect(slice).toEqual(array);
  });
 
  it("slices from a start index", function () {
    var slice = arraySlice(array, 1);
    expect(slice).toEqual([2, 3, 4, 5]);
  });
 
  it("slices from with an end index", function () {
    var slice = arraySlice(array, undefined, 3);
    expect(slice).toEqual([1, 2, 3]);
  });
 
  it("slices with a start and end index", function () {
    var slice = arraySlice(array, 1, 3);
    expect(slice).toEqual([2, 3]);
  });
 
  it("slices typed arrays", function () {
    if (!FeatureDetection.supportsTypedArrays()) {
      return;
    }
 
    var array = new Uint8Array([1, 2, 3, 4, 5]);
    var slice = arraySlice(array);
    expect(slice).toEqual(array);
  });
 
  it("throws if begin is not a number", function () {
    expect(function () {
      return arraySlice(array, {});
    }).toThrowDeveloperError();
  });
 
  it("throws if end is not a number", function () {
    expect(function () {
      return arraySlice(array, undefined, {});
    }).toThrowDeveloperError();
  });
});