mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
refactor: reduce code duplication in FloodFill (#1645)
* tests: add tests checking if floodFill funtions throw when location is outside * refactor: reduce code duplication by adding `checkLocation` to `FloodFill` * refactor: add and use `isInside` Co-authored-by: appgurueu <34514239+appgurueu@users.noreply.github.com> * Deduplicate further --------- Co-authored-by: appgurueu <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,19 @@ describe('FloodFill', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe.each([breadthFirstSearch, depthFirstSearch])('%o', (floodFillFun) => {
|
||||
it.each([
|
||||
[1, -1],
|
||||
[-1, 1],
|
||||
[0, 7],
|
||||
[7, 0]
|
||||
])('throws for start position [%i, %i]', (location) => {
|
||||
expect(() =>
|
||||
floodFillFun(generateTestRgbData(), location, green, orange)
|
||||
).toThrowError()
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Utility-function to test the function "breadthFirstSearch".
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user