Complete the code to define a property test function using Kotest.
fun testAddition() = property({ forAll<Int, Int> { a, b -> (a + b) [1] (b + a) } })The property test checks if addition is commutative by asserting a + b == b + a.
Complete the code to generate random strings for property testing.
val stringGen = Gen.[1](5..10)
We use Gen.string to generate random strings of length between 5 and 10.
Fix the error in the property test that checks list reversal.
property({ forAll<List<Int>> { list -> list.reversed().reversed() [1] list } })The test asserts that reversing a list twice returns the original list, so we use == to check equality.
Fill both blanks to create a property test that checks if sorting a list keeps its size unchanged.
property({ forAll<List<Int>> { list -> list.sorted().[1] list.size && list.size [2] list.sorted().size } })The test checks that the size of the sorted list equals the original list size, so we use size == and == operators.
Fill all three blanks to create a property test that checks if concatenating two strings has length equal to the sum of their lengths.
property({ forAll<String, String> { s1, s2 -> (s1 + s2).[1] == s1.[2] + s2.[3] } })count or size which are not properties of String in KotlinThe property test checks that the length of the concatenated string equals the sum of the lengths of the two strings. The correct property to use is length.