Skip to content

Commit

Permalink
[nodejs] Add test case for stream - streamToString
Browse files Browse the repository at this point in the history
Impacted tests(approved): new 4, update 0, delete 0
Unit test platform: Ubuntu 16.04
Unit test result summary: pass 4, fail 0, block 0
  • Loading branch information
zhaoming0 committed Apr 23, 2018
1 parent d0a9620 commit ca15dc2
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions wrappers/nodejs/test/test-streamprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,78 @@ describe('StreamProfile test', function() {
});
});

it('Testing mothod getExtrinsicsTo - 0 argument', () => {
it('Testing method getExtrinsicsTo - 0 argument', () => {
streamProfiles.forEach( (stream) => {
assert.throws(() => {
stream.getExtrinsicsTo();
});
});
});

it('Testing mothod getExtrinsicsTo - valid argument', () => {
it('Testing method getExtrinsicsTo - valid argument', () => {
let ExtrinsicsObject;
assert.doesNotThrow(() => {
ExtrinsicsObject = streamProfiles[0].getExtrinsicsTo(streamProfiles[1]);
});
assert.equal(Object.prototype.toString.call(ExtrinsicsObject.rotation), '[object Array]');
});

it('Testing mothod getExtrinsicsTo - invalid argument', () => {
it('Testing method getExtrinsicsTo - invalid argument', () => {
assert.throws(() => {
streamProfiles[0].getExtrinsicsTo('dummy');
});
});

it('Testing method streamToString - with stream number', () => {
const streams = [
'any',
'depth',
'color',
'infrared',
'fisheye',
'gyro',
'accel',
'gpio',
'pose',
'confidence',
];
assert.doesNotThrow(() => {
for (let i = rs2.stream.STREAM_ANY; i < rs2.stream.STREAM_COUNT; i++) {
let res = rs2.stream.streamToString(i);
assert.equal(res, streams[i]);
}
});
});

it('Testing method streamToString - with two arguments', () => {
assert.throws(() => {
rs2.stream.streamToString(1, 1);
});
});

it('Testing method streamToString - without argument', () => {
assert.throws(() => {
rs2.stream.streamToString();
});
});

it('Testing method streamToString - with stream string', () => {
const streams = [
'stream_any',
'stream_depth',
'stream_color',
'stream_infrared',
'stream_fisheye',
'stream_gyro',
'stream_accel',
'stream_gpio',
'stream_pose',
'stream_confidence',
];
streams.forEach((s) => {
assert.doesNotThrow(() => {
rs2.stream.streamToString(rs2.stream[s]);
});
});
});
});

0 comments on commit ca15dc2

Please sign in to comment.