Skip to content

Commit da11963

Browse files
authored
test: add test cases for blas/base/dtrsv
PR-URL: #6708 Reviewed-by: Athan Reines <[email protected]>
1 parent 0b47cf8 commit da11963

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ function dtrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
7272
if ( N < 0 ) {
7373
throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) );
7474
}
75+
if ( strideA1 === 0 ) {
76+
throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) );
77+
}
78+
if ( strideA2 === 0 ) {
79+
throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) );
80+
}
7581
if ( strideX === 0 ) {
7682
throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) );
7783
}

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

Lines changed: 46 additions & 0 deletions
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+
dtrsv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), value, data.strideA2, data.offsetA, new Float64Array( 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+
dtrsv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, value, data.offsetA, new Float64Array( 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)