Skip to content

Commit 7df446e

Browse files
author
patched.codes[bot]
committed
Patched tests/cicd/generate_docstring/kotlin_test_file.kt
1 parent 74dd568 commit 7df446e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/cicd/generate_docstring/kotlin_test_file.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,27 @@ import java.sql.ResultSet
55
import kotlin.random.Random
66

77

8+
/**
9+
* Computes the sum of two numeric values by converting them to Double.
10+
*
11+
* This function accepts any type that extends Number, converts the values to Double,
12+
* and returns the sum as a Double.
13+
*
14+
* @param a The first numeric value of type T, where T extends Number.
15+
* @param b The second numeric value of type T, where T extends Number.
16+
* @return The sum of a and b as a Double.
17+
*/
818
fun <T : Number> aPlusB(a: T, b: T): Double = a.toDouble() + b.toDouble()
919

1020

21+
/**
22+
* Executes a SQL query on a given database connection and returns the results as a list of lists.
23+
* Each inner list represents a row from the result set, with each element corresponding to a column value.
24+
*
25+
* @param db The database connection to use for executing the query.
26+
* @param query The SQL query to be executed on the database.
27+
* @return A list of rows, where each row is represented as a list of objects. Each object corresponds to a column value in the result set. Returns an empty list if no results are found.
28+
*/
1129
fun sqlite(db: Connection, query: String): List<List<Any?>> {
1230
db.createStatement().use { statement ->
1331
statement.executeQuery(query).use { resultSet ->
@@ -27,6 +45,15 @@ fun sqlite(db: Connection, query: String): List<List<Any?>> {
2745
}
2846

2947

48+
/**
49+
* Compares two items using a provided key mapping function, which extracts a comparable value from each item.
50+
* Returns -1 if the first item is less than the second, 1 if it is greater, and 0 if they are equal, based on the comparable value.
51+
*
52+
* @param keyMap A function that maps an item of type T to a comparable value of type R.
53+
* @param item1 The first item to be compared.
54+
* @param item2 The second item to be compared.
55+
* @return An integer result of the comparison: -1, 0, or 1.
56+
*/
3057
fun <T, R : Comparable<R>> compare(keyMap: (T) -> R, item1: T, item2: T): Int {
3158
return when {
3259
keyMap(item1) < keyMap(item2) -> -1
@@ -36,6 +63,13 @@ fun <T, R : Comparable<R>> compare(keyMap: (T) -> R, item1: T, item2: T): Int {
3663
}
3764

3865

66+
/**
67+
* Generates a random string of alphabets with the specified length.
68+
* The string includes both lowercase and uppercase English letters.
69+
*
70+
* @param length The desired length of the randomly generated string.
71+
* @return A string consisting of random uppercase and lowercase alphabets.
72+
*/
3973
fun randomAlphabets(length: Int): String {
4074
val charPool = ('a'..'z') + ('A'..'Z')
4175
return (1..length)

0 commit comments

Comments
 (0)