|
1 |
| -/* globals describe, beforeEach, expect, it, MCut */ |
| 1 | +/* globals describe, beforeEach, expect, it, MCut, Uint32Array, Uint16Array, Uint8Array, Uint8ClampedArray */ |
2 | 2 |
|
3 | 3 | /*********************************************************************
|
4 | 4 | * CUSTOM MATCHERS *
|
@@ -164,4 +164,29 @@ describe('MCut.get_dynamic_size_palette', function() {
|
164 | 164 | expect(result2.length).toBeGreaterThanOrEqualTo(result1.length);
|
165 | 165 | });
|
166 | 166 |
|
| 167 | + it('accepts typed arrays', function() { |
| 168 | + var data_uint32 = [new Uint32Array(181, 156, 126), new Uint32Array(215, 239, 132), new Uint32Array(187, 153, 243), new Uint32Array(209, 139, 195), new Uint32Array(120, 112, 236), new Uint32Array(6, 84, 188), new Uint32Array(69, 72, 100), new Uint32Array(41, 83, 117), new Uint32Array(230, 228, 239), new Uint32Array(199, 67, 44), new Uint32Array(59, 240, 19), new Uint32Array(27, 149, 165), new Uint32Array(194, 106, 149), new Uint32Array(171, 81, 210), new Uint32Array(2, 50, 224), new Uint32Array(27, 124, 141), new Uint32Array(221, 107, 212), new Uint32Array(128, 108, 118), new Uint32Array(62, 159, 18), new Uint32Array(111, 177, 17)]; |
| 169 | + var data_uint16 = [new Uint16Array(181, 156, 126), new Uint16Array(215, 239, 132), new Uint16Array(187, 153, 243), new Uint16Array(209, 139, 195), new Uint16Array(120, 112, 236), new Uint16Array(6, 84, 188), new Uint16Array(69, 72, 100), new Uint16Array(41, 83, 117), new Uint16Array(230, 228, 239), new Uint16Array(199, 67, 44), new Uint16Array(59, 240, 19), new Uint16Array(27, 149, 165), new Uint16Array(194, 106, 149), new Uint16Array(171, 81, 210), new Uint16Array(2, 50, 224), new Uint16Array(27, 124, 141), new Uint16Array(221, 107, 212), new Uint16Array(128, 108, 118), new Uint16Array(62, 159, 18), new Uint16Array(111, 177, 17)]; |
| 170 | + var data_uint8 = [new Uint8Array(181, 156, 126), new Uint8Array(215, 239, 132), new Uint8Array(187, 153, 243), new Uint8Array(209, 139, 195), new Uint8Array(120, 112, 236), new Uint8Array(6, 84, 188), new Uint8Array(69, 72, 100), new Uint8Array(41, 83, 117), new Uint8Array(230, 228, 239), new Uint8Array(199, 67, 44), new Uint8Array(59, 240, 19), new Uint8Array(27, 149, 165), new Uint8Array(194, 106, 149), new Uint8Array(171, 81, 210), new Uint8Array(2, 50, 224), new Uint8Array(27, 124, 141), new Uint8Array(221, 107, 212), new Uint8Array(128, 108, 118), new Uint8Array(62, 159, 18), new Uint8Array(111, 177, 17)]; |
| 171 | + var data_uint8c = [new Uint8ClampedArray(181, 156, 126), new Uint8ClampedArray(215, 239, 132), new Uint8ClampedArray(187, 153, 243), new Uint8ClampedArray(209, 139, 195), new Uint8ClampedArray(120, 112, 236), new Uint8ClampedArray(6, 84, 188), new Uint8ClampedArray(69, 72, 100), new Uint8ClampedArray(41, 83, 117), new Uint8ClampedArray(230, 228, 239), new Uint8ClampedArray(199, 67, 44), new Uint8ClampedArray(59, 240, 19), new Uint8ClampedArray(27, 149, 165), new Uint8ClampedArray(194, 106, 149), new Uint8ClampedArray(171, 81, 210), new Uint8ClampedArray(2, 50, 224), new Uint8ClampedArray(27, 124, 141), new Uint8ClampedArray(221, 107, 212), new Uint8ClampedArray(128, 108, 118), new Uint8ClampedArray(62, 159, 18), new Uint8ClampedArray(111, 177, 17)]; |
| 172 | + var mc = new MCut(); |
| 173 | + |
| 174 | + mc.init(data_uint32); |
| 175 | + var result_uint32 = mc.get_dynamic_size_palette(0.0); |
| 176 | + |
| 177 | + mc.init(data_uint16); |
| 178 | + var result_uint16 = mc.get_dynamic_size_palette(0.0); |
| 179 | + |
| 180 | + mc.init(data_uint8); |
| 181 | + var result_uint8 = mc.get_dynamic_size_palette(0.0); |
| 182 | + |
| 183 | + mc.init(data_uint8c); |
| 184 | + var result_uint8c = mc.get_dynamic_size_palette(0.0); |
| 185 | + |
| 186 | + expect(result_uint32).toEqual([[44, 126, 109], [186, 136, 173]]); |
| 187 | + expect(result_uint16).toEqual([[44, 126, 109], [186, 136, 173]]); |
| 188 | + expect(result_uint8 ).toEqual([[44, 126, 109], [186, 136, 173]]); |
| 189 | + expect(result_uint8c).toEqual([[44, 126, 109], [186, 136, 173]]); |
| 190 | + }); |
| 191 | + |
167 | 192 | });
|
0 commit comments