Skip to content

Commit 756afa3

Browse files
committed
test: add boolean array tests
1 parent 5f8d50d commit 756afa3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lib/node_modules/@stdlib/array/base/with/test/test.assign.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ var tape = require( 'tape' );
2424
var Int32Array = require( '@stdlib/array/int32' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var Complex128Array = require( '@stdlib/array/complex128' );
27+
var BooleanArray = require( '@stdlib/array/bool' );
2728
var AccessorArray = require( '@stdlib/array/base/accessor' );
2829
var Complex128 = require( '@stdlib/complex/float64/ctor' );
2930
var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' );
31+
var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' );
3032
var zeros = require( '@stdlib/array/zeros' );
3133
var arrayWith = require( './../lib/assign.js' );
3234

@@ -352,6 +354,38 @@ tape( 'the function copies elements to another array and sets an element at a sp
352354
t.end();
353355
});
354356

357+
tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (bool)', function test( t ) {
358+
var expected;
359+
var actual;
360+
var out;
361+
var x;
362+
363+
x = new BooleanArray( [ 0, 0, 0, 0 ] );
364+
365+
out = new BooleanArray( x.length );
366+
expected = new BooleanArray( [ 1, 0, 0, 0 ] );
367+
actual = arrayWith( x, 0, true, out, 1, 0 );
368+
369+
t.strictEqual( actual, out, 'returns expected value' );
370+
t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
371+
372+
out = new BooleanArray( x.length*2 );
373+
expected = new BooleanArray( [ 0, 0, 1, 0, 0, 0, 0, 0 ] );
374+
actual = arrayWith( x, 1, true, out, 2, 0 );
375+
376+
t.strictEqual( actual, out, 'returns expected value' );
377+
t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
378+
379+
out = new BooleanArray( x.length*2 );
380+
expected = new BooleanArray( [ 0, 0, 0, 1, 0, 0, 0, 0 ] );
381+
actual = arrayWith( x, 2, true, out, -2, out.length-1 );
382+
383+
t.strictEqual( actual, out, 'returns expected value' );
384+
t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
385+
386+
t.end();
387+
});
388+
355389
tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (accessors)', function test( t ) {
356390
var expected;
357391
var actual;

0 commit comments

Comments
 (0)