Skip to content

Commit 8a48ebe

Browse files
authored
test: add test cases for blas/base/strmv
PR-URL: #6732 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 9d961d3 commit 8a48ebe

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/node_modules/@stdlib/blas/base/strmv/lib/ndarray.js

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ var base = require( './base.js' );
4747
* @throws {TypeError} second argument must be a valid transpose operation
4848
* @throws {TypeError} third argument must be a valid diagonal type
4949
* @throws {RangeError} fourth argument must be a nonnegative integer
50+
* @throws {RangeError} sixth argument must be non-zero
51+
* @throws {RangeError} seventh argument must be non-zero
5052
* @throws {RangeError} tenth argument must be non-zero
5153
* @returns {Float32Array} `x`
5254
*
@@ -72,6 +74,12 @@ function strmv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
7274
if ( N < 0 ) {
7375
throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) );
7476
}
77+
if ( strideA1 === 0 ) {
78+
throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) );
79+
}
80+
if ( strideA2 === 0 ) {
81+
throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) );
82+
}
7583
if ( strideX === 0 ) {
7684
throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) );
7785
}

lib/node_modules/@stdlib/blas/base/strmv/test/test.ndarray.js

+46
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,52 @@ tape( 'the function throws an error if provided an invalid fourth argument', fun
180180
}
181181
});
182182

183+
tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) {
184+
var values;
185+
var data;
186+
var i;
187+
188+
data = rutu;
189+
190+
values = [
191+
0
192+
];
193+
194+
for ( i = 0; i < values.length; i++ ) {
195+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
196+
}
197+
t.end();
198+
199+
function badValue( value ) {
200+
return function badValue() {
201+
strmv( data.uplo, data.trans, data.diag, data.N, new Float32Array( data.A ), value, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX );
202+
};
203+
}
204+
});
205+
206+
tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) {
207+
var values;
208+
var data;
209+
var i;
210+
211+
data = rutu;
212+
213+
values = [
214+
0
215+
];
216+
217+
for ( i = 0; i < values.length; i++ ) {
218+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
219+
}
220+
t.end();
221+
222+
function badValue( value ) {
223+
return function badValue() {
224+
strmv( data.uplo, data.trans, data.diag, data.N, new Float32Array( data.A ), data.strideA1, value, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX );
225+
};
226+
}
227+
});
228+
183229
tape( 'the function throws an error if provided an invalid tenth argument', function test( t ) {
184230
var values;
185231
var data;

0 commit comments

Comments
 (0)