<commit_before>package com.github.vok.framework.sql2o

import org.junit.Test
import kotlin.test.expect

class FiltersTest {
    @Test
    fun testToSQL92() {
        expect("age = :25") { sql { com.github.vok.framework.sql2o.Person::age eq 25 } }
        expect("(age >= :25 and age <= :50)") { sql { com.github.vok.framework.sql2o.Person::age between 25..50 } }
    }

    @Test
    fun testLikeFilterInMemory() {
        expect(true) { LikeFilter<Person>("name", "A").test(Person(name = "kari", age = 35)) }
        expect(true) { LikeFilter<Person>("name", " a ").test(Person(name = "kari", age = 35)) }
    }

    private fun sql(block: SqlWhereBuilder<Person>.()->Filter<Person>): String {
        val filter: Filter<Person> = block(SqlWhereBuilder())
        return unmangleParameterNames(filter.toSQL92(), filter.getSQL92Parameters())
    }

    private fun unmangleParameterNames(sql: String, params: Map<String, Any?>): String {
        var sql = sql
        params.entries.forEach { (key, value) -> sql = sql.replace(":$key", ":$value") }
        return sql
    }
}<commit_msg>Fixed FiltersTest<commit_after>package com.github.vok.framework.sql2o

import org.junit.Test
import kotlin.test.expect

class FiltersTest {
    @Test
    fun testToSQL92() {
        expect("age = :25") { sql { com.github.vok.framework.sql2o.Person::age eq 25 } }
        expect("(age >= :25 and age <= :50)") { sql { com.github.vok.framework.sql2o.Person::age between 25..50 } }
    }

    @Test
    fun testLikeFilterInMemory() {
        expect(false) { LikeFilter<Person>("name", "A").test(Person(name = "kari", age = 35)) }
        expect(true) { LikeFilter<Person>("name", " a ").test(Person(name = "kari", age = 35)) }
        expect(true) { ILikeFilter<Person>("name", "A").test(Person(name = "kari", age = 35)) }
    }

    private fun sql(block: SqlWhereBuilder<Person>.()->Filter<Person>): String {
        val filter: Filter<Person> = block(SqlWhereBuilder())
        return unmangleParameterNames(filter.toSQL92(), filter.getSQL92Parameters())
    }

    private fun unmangleParameterNames(sql: String, params: Map<String, Any?>): String {
        var sql = sql
        params.entries.forEach { (key, value) -> sql = sql.replace(":$key", ":$value") }
        return sql
    }
}
{'fraction_non_alphanumeric': 0.1665934065934066, 'fraction_numerical': 0.022857142857142857, 'mean_word_length': 3.286252354048964, 'pattern_counts': {'":': 4, '<': 18, '<?xml version=': 0, '>': 22, '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': '3957221', 'n_tokens_mistral': 767, 'n_tokens_neox': 732, 'n_words': 153}