Added testcases for Zero One Knapsack (#1109)

This commit is contained in:
Nitin Ramnani
2022-10-02 11:19:31 +05:30
committed by GitHub
parent 7a1141b637
commit 9528c71107

View File

@ -0,0 +1,15 @@
import { zeroOneKnapsack } from '../ZeroOneKnapsack'
describe('ZeroOneKnapsack', () => {
it('zeroOneKnapsack when capacity is 4 and 5 items', () => {
expect(zeroOneKnapsack([[1, 8], [2, 4], [3, 0], [2, 5], [2, 3]], 5, 4, [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]])).toBe(13)
})
it('zeroOneKnapsack when capacity is 1 and 1 items', () => {
expect(zeroOneKnapsack([[1, 80]], 1, 1, [[-1, -1], [-1, -1]])).toBe(80)
})
it('zeroOneKnapsack when capacity is 0 and 1 items', () => {
expect(zeroOneKnapsack([[1, 80]], 1, 0, [[-1], [-1]])).toBe(0)
})
})