Skip to content

Commit 3e2cf39

Browse files
committed
Add test cases for multiply prompt
1 parent 3a85a24 commit 3e2cf39

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

spec/part1.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,40 @@
480480
expect(multiply.toString()).to.not.contain('Math');
481481
});
482482

483-
it('should return the product of two integers', function() {
484-
expect(multiply(2, 1)).to.equal(2 * 1);
483+
it('should return the product of two positive integers', function() {
484+
expect(multiply(1, 2)).to.equal(1 * 2);
485+
expect(multiply(2, 1)).to.equal(1 * 2);
486+
expect(multiply(5, 17)).to.equal(5 * 17);
485487
expect(multiply(17, 5)).to.equal(17 * 5);
486488
expect(multiply(78, 453)).to.equal(78 * 453);
487-
expect(multiply(-79, 82)).to.equal(-79 * 82);
488-
expect(multiply(-275, -502)).to.equal(-275 * -502);
489+
expect(multiply(453, 78)).to.equal(78 * 453);
489490
expect(multiply(0, 32)).to.equal(0 * 32);
491+
expect(multiply(32, 0)).to.equal(0 * 32);
490492
expect(multiply(0, 0)).to.equal(0 * 0);
491493
});
492494

495+
it('should return the product of two negative integers', function() {
496+
expect(multiply(-79, -82)).to.equal(-79 * -82);
497+
expect(multiply(-275, -502)).to.equal(-275 * -502);
498+
expect(multiply(-2, -2)).to.equal(-2 * -2);
499+
expect(multiply(-8, -3)).to.equal(-8 * -3);
500+
expect(multiply(-12, -10)).to.equal(-12 * -10);
501+
expect(multiply(-22, -3)).to.equal(-22 * -3);
502+
expect(multiply(-5, -27)).to.equal(-5 * -27);
503+
});
504+
505+
it('should return the product of mixed positive and negative integers', function() {
506+
expect(multiply(-79, 82)).to.equal(-79 * 82);
507+
expect(multiply(79, -82)).to.equal(79 * -82);
508+
expect(multiply(-275, 502)).to.equal(-275 * 502);
509+
expect(multiply(275, -502)).to.equal(275 * -502);
510+
expect(multiply(2, -2)).to.equal(2 * -2);
511+
expect(multiply(-8, 3)).to.equal(-8 * 3);
512+
expect(multiply(12, -10)).to.equal(12 * -10);
513+
expect(multiply(-22, 3)).to.equal(-22 * 3);
514+
expect(multiply(5, -27)).to.equal(5 * -27);
515+
});
516+
493517
it('should use recursion by calling self', function () {
494518
var originalMultiply = multiply;
495519
multiply = sinon.spy(multiply);

0 commit comments

Comments
 (0)