Skip to content

Commit

Permalink
added tests for Backtracking/AllCombinationsOfSizeK
Browse files Browse the repository at this point in the history
  • Loading branch information
chiranjeev-thapliyal committed Oct 6, 2021
1 parent 6919e85 commit 254f90b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
17 changes: 2 additions & 15 deletions Backtracking/AllCombinationsOfSizeK.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,7 @@ class Combinations {
this.findCombinations(high, total - 1, i + 1)
this.combinationArray.pop()
}
};
}
}

/*
Driver Code
Test Case 1: n = 3, k = 2
Test Case 2: n = 4, k = 2
*/

console.log('\nFirst Test Case')
const test1 = new Combinations(3, 2)
test1.findCombinations()

console.log('\nSecond Test Case')
const test2 = new Combinations(4, 2)
test2.findCombinations()
export { Combinations }
13 changes: 13 additions & 0 deletions Backtracking/tests/AllCombinationsOfSizeK.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Combinations } from '../AllCombinationsOfSizeK'

describe('AllCombinationsOfSizeK', () => {
it('should return 3x2 matrix solution for n = 3 and k = 2', () => {
const test1 = new Combinations(3, 2)
expect(test1.findCombinations).toEqual([[1, 2], [1, 3], [2, 3]])
})

it('should return 6x2 matrix solution for n = 3 and k = 2', () => {
const test2 = new Combinations(4, 2)
expect(test2.findCombinations).toEqual([[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]])
})
})

0 comments on commit 254f90b

Please sign in to comment.