Skip to content

Instantly share code, notes, and snippets.

@eliezio
Created May 29, 2018 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliezio/4e85f934d9c289bcb86a2e6d1556c02d to your computer and use it in GitHub Desktop.
Save eliezio/4e85f934d9c289bcb86a2e6d1556c02d to your computer and use it in GitHub Desktop.
import spock.lang.Specification
import spock.lang.Unroll
class UtilsSpec extends Specification {
@Unroll
def 'flat collection of integers: #list'() {
expect:
Utils.flatIntegers(list) == expectedResult
where:
list || expectedResult
[[1, 2, [3]], 4] || [1, 2, 3, 4]
[1, 2, 3] || [1, 2, 3]
[] || []
}
@Unroll
def 'must report IAE on invalid input'() {
when:
Utils.flatIntegers(list)
then:
thrown(IllegalArgumentException)
where:
list << [
null,
[null],
[1, [2, [3, null]]],
[1, [2, [3]], 4, 'A']
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment