Created
May 29, 2018 10:52
-
-
Save eliezio/4e85f934d9c289bcb86a2e6d1556c02d to your computer and use it in GitHub Desktop.
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
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