Skip to content

Commit

Permalink
[test] Increasing coverage for Mersenne Twister
Browse files Browse the repository at this point in the history
  * Covers internal argument validation
  * This validation is already tested upstream
  • Loading branch information
Marak committed Oct 15, 2018
1 parent 3d3e373 commit 056fe63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/random.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if (typeof module !== 'undefined') {
var sinon = require('sinon');
var _ = require('lodash');
var faker = require('../index');
var mersenne = require('../vendor/mersenne');
}


Expand Down Expand Up @@ -279,4 +280,25 @@ describe("random.js", function () {
assert.ok(hex.match(/^(0x)[0-9a-f]+$/i));
})
})

describe("mersenne twister", function() {
it("returns a random number without given min / max arguments", function() {
var max = 10;
var randomNumber = mersenne.rand();
assert.ok(typeof randomNumber === 'number');
});

it("throws an error when attempting to seed() a non-integer", function() {
assert.throws(function () {
mersenne.seed('abc');
}, Error);
});

it("throws an error when attempting to seed() a non-integer", function() {
assert.throws(function () {
mersenne.seed_array('abc');
}, Error);
});
})

});

0 comments on commit 056fe63

Please sign in to comment.