realm-java
realm-java copied to clipboard
Exhaustive-type tests using generics should use an all-types enum
Having an AllTypes enum where we define all possible types that could be used in collections or dictionaries would allow us to determine in our tests whether a particular type is supported by said collections or dictionaries. If we add a new type and don't handle it correctly our tests should fail.
For example:
enum class AllTypes {
LONG, SHORT, STRING // and many more
fun isListSupported(type: AllTypes): Boolean {
return when (type) {
LONG,
SHORT -> true
SOMETHING_ELSE -> false
}
}
fun isDictionarySupported(type: AllTypes): Boolean {
// ...
}
}