-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests for enum codec & provider
- Loading branch information
1 parent
4e5313c
commit 578955b
Showing
3 changed files
with
432 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package tests.coding | ||
|
||
import ch.tutteli.atrium.api.cc.en_GB.toBe | ||
import ch.tutteli.atrium.verbs.assert | ||
import com.github.fluidsonic.fluid.json.* | ||
import org.junit.jupiter.api.Test | ||
|
||
|
||
@Suppress("UNCHECKED_CAST") | ||
internal object EnumJSONCodecProviderTest { | ||
|
||
@Test | ||
fun test() { | ||
val provider = EnumJSONCodecProvider(transformation = EnumJSONTransformation.Ordinal) | ||
val serializer = JSONCodingSerializer.builder().encodingWith(provider).build() | ||
|
||
for (enumClass in listOf(Example1::class, Example2::class)) { | ||
assert(serializer.serializeValue(enumClass.java.enumConstants.first())).toBe("0") | ||
} | ||
} | ||
|
||
|
||
private enum class Example1 { | ||
hello1 | ||
} | ||
|
||
|
||
private enum class Example2 { | ||
hello2 | ||
} | ||
} |
Oops, something went wrong.