Tests for random number snippets
This commit is contained in:
@ -5,6 +5,12 @@ test('Testing randomIntArrayInRange', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof randomIntArrayInRange === 'function', 'randomIntArrayInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
const arr = randomIntArrayInRange(lowerLimit,upperLimit, 10);
|
||||
t.true(arr.every(x => typeof x === 'number'), 'The returned array contains only integers');
|
||||
t.equal(arr.length, 10, 'The returned array has the proper length');
|
||||
t.true(arr.every(x => (x >= lowerLimit) && (x <= upperLimit)),'The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomIntArrayInRange(args..), 'Expected');
|
||||
//t.equal(randomIntArrayInRange(args..), 'Expected');
|
||||
//t.false(randomIntArrayInRange(args..), 'Expected');
|
||||
|
||||
@ -7,9 +7,9 @@ test('Testing randomIntegerInRange', (t) => {
|
||||
t.true(typeof randomIntegerInRange === 'function', 'randomIntegerInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
t.true(Number.isInteger(randomIntegerInRange(lowerLimit,upperLimit)),'The returned value is a Integer');
|
||||
t.true(Number.isInteger(randomIntegerInRange(lowerLimit,upperLimit)),'The returned value is an integer');
|
||||
const numberForTest = randomIntegerInRange(lowerLimit,upperLimit);
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provied lowerLimit and upperLimit (both inclusive).');
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomIntegerInRange(args..), 'Expected');
|
||||
//t.equal(randomIntegerInRange(args..), 'Expected');
|
||||
//t.false(randomIntegerInRange(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,11 @@ test('Testing randomNumberInRange', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof randomNumberInRange === 'function', 'randomNumberInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
t.true(typeof randomNumberInRange(lowerLimit,upperLimit) === 'number','The returned value is a number');
|
||||
const numberForTest = randomNumberInRange(lowerLimit,upperLimit);
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomNumberInRange(args..), 'Expected');
|
||||
//t.equal(randomNumberInRange(args..), 'Expected');
|
||||
//t.false(randomNumberInRange(args..), 'Expected');
|
||||
|
||||
15
test/testlog
15
test/testlog
@ -1,4 +1,4 @@
|
||||
Test log for: Fri Feb 09 2018 13:23:32 GMT+0200 (GTB Standard Time)
|
||||
Test log for: Fri Feb 09 2018 13:30:29 GMT+0200 (GTB Standard Time)
|
||||
|
||||
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||
> tape test/**/*.test.js | tap-spec
|
||||
@ -1210,16 +1210,21 @@ Test log for: Fri Feb 09 2018 13:23:32 GMT+0200 (GTB Standard Time)
|
||||
Testing randomIntArrayInRange
|
||||
|
||||
√ randomIntArrayInRange is a Function
|
||||
√ The returned array contains only integers
|
||||
√ The returned array has the proper length
|
||||
√ The returned array's values lie between provided lowerLimit and upperLimit (both inclusive).
|
||||
|
||||
Testing randomIntegerInRange
|
||||
|
||||
√ randomIntegerInRange is a Function
|
||||
√ The returned value is a Integer
|
||||
√ The returned value lies between provied lowerLimit and upperLimit (both inclusive).
|
||||
√ The returned value is an integer
|
||||
√ The returned value lies between provided lowerLimit and upperLimit (both inclusive).
|
||||
|
||||
Testing randomNumberInRange
|
||||
|
||||
√ randomNumberInRange is a Function
|
||||
√ The returned value is a number
|
||||
√ The returned value lies between provided lowerLimit and upperLimit (both inclusive).
|
||||
|
||||
Testing readFileLines
|
||||
|
||||
@ -1783,8 +1788,8 @@ Test log for: Fri Feb 09 2018 13:23:32 GMT+0200 (GTB Standard Time)
|
||||
√ Works with multiple promises
|
||||
|
||||
|
||||
total: 881
|
||||
passing: 881
|
||||
total: 886
|
||||
passing: 886
|
||||
duration: 2.4s
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user