@@ -20,7 +20,14 @@ import org.cryptomator.data.db.sqlmapping.MappingSupportSQLiteDatabase.MappingSu
2020import org.cryptomator.data.testing.ValueExtractor
2121import org.cryptomator.data.testing.anyPseudoEquals
2222import org.cryptomator.data.testing.anyPseudoEqualsUnlessNull
23+ import org.cryptomator.data.testing.argCount
2324import org.cryptomator.data.testing.asCached
25+ import org.cryptomator.data.testing.cartesianProductFour
26+ import org.cryptomator.data.testing.cartesianProductThree
27+ import org.cryptomator.data.testing.cartesianProductTwo
28+ import org.cryptomator.data.testing.nullCount
29+ import org.cryptomator.data.testing.toArgumentsStream
30+ import org.cryptomator.data.testing.toBindingsMap
2431import org.junit.jupiter.api.Assertions.assertEquals
2532import org.junit.jupiter.api.Assertions.assertInstanceOf
2633import org.junit.jupiter.api.Assertions.assertNotSame
@@ -1103,31 +1110,4 @@ fun sourceForTestNewBoundStatementNumerous2(): Stream<Arguments> {
11031110 return result //
11041111 .map { it.toList() } //
11051112 .toArgumentsStream()
1106- }
1107-
1108- fun <A , B > Sequence<A>.cartesianProductTwo (other : Iterable <B >): Sequence <Pair <A , B >> = flatMap { a ->
1109- other.asSequence().map { b -> a to b }
1110- }
1111-
1112- fun <A , B , C > Sequence <Pair <A , B >>.cartesianProductThree (other : Iterable <C >): Sequence <Triple <A , B , C >> = flatMap { abPair ->
1113- other.asSequence().map { c -> Triple (abPair.first, abPair.second, c) }
1114- }
1115-
1116- fun <T > Sequence <Triple <T , T , T >>.cartesianProductFour (other : Iterable <T >): Sequence <List <T >> = flatMap { triple ->
1117- other.asSequence().map { otherElement -> listOf (triple.first, triple.second, triple.third, otherElement) }
1118- }
1119-
1120- fun Sequence<List<Any?>>.toArgumentsStream (): Stream <Arguments > = map {
1121- Arguments { it.toTypedArray() }
1122- }.asStream()
1123-
1124- private fun Iterable<Any?>?.nullCount (): Int = this ?.count { it == null } ? : 0
1125-
1126- private inline fun <reified T > Iterable<Any?>?.argCount (): Int = this ?.asSequence()?.filterIsInstance<T >()?.count() ? : 0
1127-
1128- private fun Iterable<Any?>?.toBindingsMap (): Map <Int , Any ?> {
1129- return this ?.asSequence() //
1130- ?.map { if (it is Int ) it.toLong() else it } // Required because java.lang.Integer.valueOf(x) != java.lang.Long.valueOf(x)
1131- ?.mapIndexed { index, value -> index + 1 to value } //
1132- ?.toMap() ? : emptyMap()
11331113}
0 commit comments