Files
JavaScript/Recursive/test/Partition.test.js
Vedas Dixit e9e3ea4684 Implemented Partition Problem, Recursive problem (#1582)
* Add Tug of War solution using backtracking

* Updated Documentation in README.md

* Added Tug of war problem link

* Updated Documentation in README.md

* Updated Documentation in README.md

* Refactor tugOfWar: remove unused vars, optimize initialization, and remove redundant checks

* Added Function Export Statment

* Updated Documentation in README.md

* Resolved Code Style --Prettier

* Rename "backtrack" to "recurse"

* Fix test case: The difference needs to be exactly 1.

* Code Modification: subsets should have sizes as close to n/2 as possible

* Updated test-case of TugOfWar

* Changed TugOfWar problem to Partition

* Modified partition problem

* Updated Documentation in README.md

* fixed code style

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
2023-11-15 19:22:57 +05:30

25 lines
796 B
JavaScript

import { canPartition } from '../Partition'
describe('Partition (Recursive)', () => {
it('expects to return true for an array that can be partitioned', () => {
const result = canPartition([1, 5, 11, 5])
expect(result).toBe(true)
})
it('expects to return false for an array that cannot be partitioned', () => {
const result = canPartition([1, 2, 3, 5])
expect(result).toBe(false)
})
it('expects to return true for an empty array (0 elements)', () => {
const result = canPartition([])
expect(result).toBe(true)
})
it('Throw Error for Invalid Input', () => {
expect(() => canPartition(123)).toThrow('Invalid Input')
expect(() => canPartition(null)).toThrow('Invalid Input')
expect(() => canPartition(undefined)).toThrow('Invalid Input')
})
})