-
Notifications
You must be signed in to change notification settings - Fork 7
/
JSONEncoderTests.groovy
38 lines (30 loc) · 985 Bytes
/
JSONEncoderTests.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package json.tests
import com.howardlewisship.tapx.json.JSONEncoder
import com.howardlewisship.tapx.json.JSONModule
import org.apache.tapestry5.ioc.Registry
import org.apache.tapestry5.ioc.RegistryBuilder
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
/**
* Tests various implementations of {@link com.howardlewisship.tapx.json.JSONEncoder}.
*/
class JSONEncoderTests extends Specification {
@Shared
Registry registry = new RegistryBuilder().add(JSONModule.class).build();
@Shared
JSONEncoder encoder = registry.getService(JSONEncoder.class)
@Unroll("JSON encoding of #input should be #expected")
def "encoding of simple value types"() {
expect:
encoder.encodeAsJSON(input) == expected
where:
input | expected
"a string" | "a string"
5 | 5
false | false
true | true
3.75f | 3.75f
null | null
}
}