test: coverage
All checks were successful
Check PR code / Lint (pull_request) Successful in 1m13s
Check PR code / build (pull_request) Successful in 9m43s

This commit is contained in:
2024-12-29 21:35:12 +01:00
parent aad93ef722
commit f54fcc3ba1
30 changed files with 1474 additions and 192 deletions

View File

@ -6,9 +6,16 @@ import com.russhwolf.settings.Settings
// This is to fix ACRA not sending reports anymore.
// See https://www.acra.ch/docs/Troubleshooting-Guide#applicationoncreate
class ACRASettings : Settings {
override val keys: Set<String> = emptySet()
override val keys: MutableSet<String> = mutableSetOf()
override val size: Int = 0
val bools: MutableMap<String, Boolean> = mutableMapOf()
val doubles: MutableMap<String, Double> = mutableMapOf()
val floats: MutableMap<String, Float> = mutableMapOf()
val ints: MutableMap<String, Int> = mutableMapOf()
val longs: MutableMap<String, Long> = mutableMapOf()
val strings: MutableMap<String, String> = mutableMapOf()
override fun clear() {
// Nothing
}
@ -16,90 +23,102 @@ class ACRASettings : Settings {
override fun getBoolean(
key: String,
defaultValue: Boolean,
): Boolean = false
): Boolean = bools[key] ?: defaultValue
override fun getBooleanOrNull(key: String): Boolean? = null
override fun getBooleanOrNull(key: String): Boolean? = bools[key]
override fun getDouble(
key: String,
defaultValue: Double,
): Double = 0.0
): Double = doubles[key] ?: defaultValue
override fun getDoubleOrNull(key: String): Double? = null
override fun getDoubleOrNull(key: String): Double? = doubles[key]
override fun getFloat(
key: String,
defaultValue: Float,
): Float = 0.0F
): Float = floats[key] ?: defaultValue
override fun getFloatOrNull(key: String): Float? = null
override fun getFloatOrNull(key: String): Float? = floats[key]
override fun getInt(
key: String,
defaultValue: Int,
): Int = 0
): Int = ints[key] ?: defaultValue
override fun getIntOrNull(key: String): Int? = null
override fun getIntOrNull(key: String): Int? = ints[key]
override fun getLong(
key: String,
defaultValue: Long,
): Long = 0
): Long = longs[key] ?: defaultValue
override fun getLongOrNull(key: String): Long? = null
override fun getLongOrNull(key: String): Long? = longs[key]
override fun getString(
key: String,
defaultValue: String,
): String = "0"
): String = strings[key] ?: defaultValue
override fun getStringOrNull(key: String): String? = null
override fun getStringOrNull(key: String): String? = strings[key]
override fun hasKey(key: String): Boolean = false
override fun hasKey(key: String): Boolean = keys.contains(key)
override fun putBoolean(
key: String,
value: Boolean,
) {
// Nothing
keys.add(key)
bools[key] = value
}
override fun putDouble(
key: String,
value: Double,
) {
// Nothing
keys.add(key)
doubles[key] = value
}
override fun putFloat(
key: String,
value: Float,
) {
// Nothing
keys.add(key)
floats[key] = value
}
override fun putInt(
key: String,
value: Int,
) {
// Nothing
keys.add(key)
ints[key] = value
}
override fun putLong(
key: String,
value: Long,
) {
// Nothing
keys.add(key)
longs[key] = value
}
override fun putString(
key: String,
value: String,
) {
// Nothing
keys.add(key)
strings[key] = value
}
override fun remove(key: String) {
// Nothing
keys.remove(key)
bools.remove(key)
doubles.remove(key)
floats.remove(key)
ints.remove(key)
longs.remove(key)
strings.remove(key)
}
}
}