Skip to content

Commit 0ba71a8

Browse files
committed
test: add test case
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 3c34260 commit 0ba71a8

File tree

1 file changed

+76
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/fill-slice/test

1 file changed

+76
-0
lines changed

lib/node_modules/@stdlib/ndarray/fill-slice/test/test.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,82 @@ tape( 'the function fills an input ndarray slice with a specified value (row-maj
258258
t.end();
259259
});
260260

261+
tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous)', function test( t ) {
262+
var expected;
263+
var ord;
264+
var sh;
265+
var st;
266+
var dt;
267+
var s0;
268+
var s1;
269+
var s2;
270+
var o;
271+
var x;
272+
273+
dt = 'float64';
274+
ord = 'row-major';
275+
sh = [ 3, 1, 2 ];
276+
st = shape2strides( sh, ord );
277+
o = strides2offset( sh, st );
278+
279+
x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord );
280+
s0 = new Slice( 0, 2 );
281+
s1 = new Slice( null, null );
282+
s2 = new Slice( null, null );
283+
284+
fillSlice( x, 10.0, [ s0, s1, s2 ] );
285+
286+
expected = new Float64Array([
287+
10.0,
288+
10.0,
289+
10.0,
290+
10.0,
291+
0.0,
292+
0.0
293+
]);
294+
295+
t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' );
296+
t.end();
297+
});
298+
299+
tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous)', function test( t ) {
300+
var expected;
301+
var ord;
302+
var sh;
303+
var st;
304+
var dt;
305+
var s0;
306+
var s1;
307+
var s2;
308+
var o;
309+
var x;
310+
311+
dt = 'float64';
312+
ord = 'row-major';
313+
sh = [ 3, 1, 2 ];
314+
st = shape2strides( sh, ord );
315+
o = strides2offset( sh, st );
316+
317+
x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord );
318+
s0 = new Slice( 0, 2 );
319+
s1 = new Slice( null, null );
320+
s2 = new Slice( null, null );
321+
322+
fillSlice( x, 10.0, s0, s1, s2 );
323+
324+
expected = new Float64Array([
325+
10.0,
326+
10.0,
327+
10.0,
328+
10.0,
329+
0.0,
330+
0.0
331+
]);
332+
333+
t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' );
334+
t.end();
335+
});
336+
261337
tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, options)', function test( t ) {
262338
var expected;
263339
var ord;

0 commit comments

Comments
 (0)