<commit_before>package com.doctoror.particleswallpaper.presentation.preference

import android.content.Context
import android.support.test.InstrumentationRegistry
import org.junit.Test
import kotlin.test.assertEquals

/**
 * Created by <NAME> on 30.05.17.
 */
class SeekBarSettingsPreferencesTest {

    @Test
    fun testDotScalePreference() {
        testMapper(DotScalePreference::class.java)
    }

    @Test
    fun testFrameDelayPreference() {
        testMapper(FrameDelayPreference::class.java)
    }

    @Test
    fun testFrameDelayPreferenceMinValue() {
        val p = newInstance(FrameDelayPreference::class.java)
        assertEquals(p.frameDelaySeekbarMin, p.transformToRealValue(p.max))
    }

    private fun <T, A> testMapper(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        testMapperMinValue(pClass)
        testMapperMaxValue(pClass)
    }

    private fun <T, A> testMapperMinValue(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        val p = newInstance(pClass)
        val seekBarValue = 0
        val frameDelay = p.transformToRealValue(seekBarValue)
        assertEquals(seekBarValue, p.transformToProgress(frameDelay))
    }

    private fun <T, A> testMapperMaxValue(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        val p = newInstance(pClass)
        val seekBarValue = p.max
        val frameDelay = p.transformToRealValue(seekBarValue)
        assertEquals(seekBarValue, p.transformToProgress(frameDelay))
    }

    fun <T, A> newInstance(pClass: Class<T>): T where T : SeekBarPreference, T : MapperSeekbarPreference<A> {<commit_msg>Added tests for all preferences.<commit_after>package com.doctoror.particleswallpaper.presentation.preference

import android.content.Context
import android.support.test.InstrumentationRegistry
import org.junit.Test
import kotlin.test.assertEquals

/**
 * Created by <NAME> on 30.05.17.
 */
class SeekBarSettingsPreferencesTest {

    @Test
    fun testDotScalePreference() {
        testMapper(DotScalePreference::class.java)
    }

    @Test
    fun testFrameDelayPreference() {
        testMapper(FrameDelayPreference::class.java)
    }

    @Test
    fun testFrameDelayPreferenceMinValue() {
        val p = newInstance(FrameDelayPreference::class.java)
        assertEquals(p.frameDelaySeekbarMin, p.transformToRealValue(p.max))
    }

    @Test
    fun testLineDistancePreference() {
        testMapper(LineDistancePreference::class.java)
    }

    @Test
    fun testLineScalePreference() {
        testMapper(LineScalePreference::class.java)
    }

    @Test
    fun testNumDotsPreference() {
        testMapper(NumDotsPreference::class.java)
    }

    @Test
    fun testSpeedFactorPreference() {
        testMapper(SpeedFactorPreference::class.java)
    }

    private fun <T, A> testMapper(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        testMapperMinValue(pClass)
        testMapperMaxValue(pClass)
    }

    private fun <T, A> testMapperMinValue(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        val p = newInstance(pClass)
        val seekBarValue = 0
        val frameDelay = p.transformToRealValue(seekBarValue)
        assertEquals(seekBarValue, p.transformToProgress(frameDelay))
    }

    private fun <T, A> testMapperMaxValue(pClass: Class<T>)
            where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
        val p = newInstance(pClass)
        val seekBarValue = p.max
        val frameDelay = p.transformToRealValue(seekBarValue)
        assertEquals(seekBarValue, p.transformToProgress(frameDelay))
    }

    fun <T, A> newInstance(pClass: Class<T>): T where T : SeekBarPreference, T : MapperSeekbarPreference<A> {
{'fraction_non_alphanumeric': 0.09320939839917376, 'fraction_numerical': 0.0036147689129873485, 'mean_word_length': 3.3724604966139955, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3757448', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1172, 'n_words': 222}