-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from d3vco/master
Allow incomplete fact selection
- Loading branch information
Showing
4 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { cartesian } from '../utils/utils'; | ||
|
||
describe('cartesian function', () => { | ||
it('should return an empty array when input is empty', () => { | ||
expect(cartesian([])).toEqual([]); | ||
}); | ||
|
||
it('should return the correct cartesian product for non-empty arrays', () => { | ||
const input = [[1, 2], [3, 4]]; | ||
const expectedOutput = [ | ||
[1, 3], | ||
[1, 4], | ||
[2, 3], | ||
[2, 4] | ||
]; | ||
expect(cartesian(input)).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should allow arrays with empty sub-arrays', () => { | ||
const input = [[1, 2], [], [3, 4]]; | ||
const expectedOutput = [ | ||
[1, 3], | ||
[1, 4], | ||
[2, 3], | ||
[2, 4] | ||
]; | ||
expect(cartesian(input)).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle arrays with single elements', () => { | ||
const input = [[1], [2], [3]]; | ||
const expectedOutput = [ | ||
[1, 2, 3] | ||
]; | ||
expect(cartesian(input)).toEqual(expectedOutput); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters