Skip to content

Commit

Permalink
Updated tests for up to 8 dice. #4
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuth committed Feb 18, 2017
1 parent d721364 commit 5217e56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ QUnit.test("Base 6 conversion", function(assert) {
assert.deepEqual(Diceware.getBase6(216, 4), [1, 0, 0, 0]);
assert.deepEqual(Diceware.getBase6(1080, 4), [5, 0, 0, 0]);
assert.deepEqual(Diceware.getBase6(1295, 4), [5, 5, 5, 5]);
assert.deepEqual(Diceware.getBase6(7775, 5), [5, 5, 5, 5, 5]);
assert.deepEqual(Diceware.getBase6(46655, 6), [5, 5, 5, 5, 5, 5]);
assert.deepEqual(Diceware.getBase6(279935, 7), [5, 5, 5, 5, 5, 5, 5]);
assert.deepEqual(Diceware.getBase6(1679615, 8), [5, 5, 5, 5, 5, 5, 5, 5]);

assert.throws(function() {Diceware.getBase6(6, 1); }, /too large/, "Value too large");
assert.throws(function() {Diceware.getBase6(36, 2); }, /too large/, "Value too large");
Expand All @@ -52,6 +56,10 @@ QUnit.test("Convert Base 6 to Dice Roll", function(assert) {
assert.deepEqual(Diceware.convertBase6ToDice([1, 0, 0, 0], 4), [2, 1, 1, 1]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 0, 0, 0], 4), [6, 1, 1, 1]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 5, 5, 5], 4), [6, 6, 6, 6]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 5, 5, 5, 5], 5), [6, 6, 6, 6, 6]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 5, 5, 5, 5, 5], 6), [6, 6, 6, 6, 6, 6]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 5, 5, 5, 5, 5, 5], 7), [6, 6, 6, 6, 6, 6, 6]);
assert.deepEqual(Diceware.convertBase6ToDice([5, 5, 5, 5, 5, 5, 5, 5], 8), [6, 6, 6, 6, 6, 6, 6, 6]);

assert.throws(function() {Diceware.convertBase6ToDice([-1], 1); }, /negative/, "Negative value");
assert.throws(function() {Diceware.convertBase6ToDice([0, -1], 2); }, /negative/, "Negative value");
Expand All @@ -75,6 +83,10 @@ QUnit.test("Roll some dice!", function(assert) {
assert.equal(Diceware.getNumValuesFromNumDice(2), 36);
assert.equal(Diceware.getNumValuesFromNumDice(3), 216);
assert.equal(Diceware.getNumValuesFromNumDice(4), 1296);
assert.equal(Diceware.getNumValuesFromNumDice(5), 7776);
assert.equal(Diceware.getNumValuesFromNumDice(6), 46656);
assert.equal(Diceware.getNumValuesFromNumDice(7), 279936);
assert.equal(Diceware.getNumValuesFromNumDice(8), 1679616);

assert.throws(function() {Diceware.getNumValuesFromNumDice(0); }, /zero/, "Zero");
assert.throws(function() {Diceware.getNumValuesFromNumDice(-1); }, /negative/, "Negative value");
Expand Down

0 comments on commit 5217e56

Please sign in to comment.