Skip to content

Commit c1db0c2

Browse files
author
patched.codes[bot]
committed
Patched tests/cicd/generate_docstring/cpp_test_file.cpp
1 parent 434c93b commit c1db0c2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/cicd/generate_docstring/cpp_test_file.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@
66

77

88
template<typename T>
9+
/**
10+
* Adds two values of the same type.
11+
*
12+
* @param a The first value to be added.
13+
* @param b The second value to be added.
14+
* @return The result of adding a and b.
15+
*/
916
T a_plus_b(T a, T b) {
1017
return a + b;
1118
}
1219

1320

21+
/**
22+
* Executes a SQL query on the given SQLite database and returns the results.
23+
*
24+
* @param db A pointer to the SQLite database object.
25+
* @param query A string containing the SQL query to be executed.
26+
* @return A vector of vectors of strings where each sub-vector represents a row from the query result,
27+
* with each string in the sub-vector corresponding to a column value. Returns an empty vector
28+
* if the query fails to prepare.
29+
*/
30+
1431
std::vector<std::vector<std::string>> sqlite(sqlite3* db, const std::string& query) {
1532
std::vector<std::vector<std::string>> results;
1633
sqlite3_stmt* stmt;
@@ -38,6 +55,15 @@ std::vector<std::vector<std::string>> sqlite(sqlite3* db, const std::string& que
3855

3956

4057
template<typename T, typename F>
58+
/**
59+
* Compares two items based on a key mapping function and returns an integer indicating their order.
60+
*
61+
* @param key_map A function that extracts a comparison key from an item.
62+
* @param item1 The first item to be compared.
63+
* @param item2 The second item to be compared.
64+
* @return -1 if the first item is less than the second, 1 if the first item is greater than the second,
65+
* and 0 if they are equal based on the mapping function.
66+
*/
4167
int compare(F key_map, const T& item1, const T& item2) {
4268
auto val1 = key_map(item1);
4369
auto val2 = key_map(item2);
@@ -48,6 +74,12 @@ int compare(F key_map, const T& item1, const T& item2) {
4874
}
4975

5076

77+
/**
78+
* Generates a random string composed of lowercase and uppercase alphabets.
79+
*
80+
* @param length The length of the random string to be generated.
81+
* @return A random string containing only alphabetic characters with the specified length.
82+
*/
5183
std::string random_alphabets(int length) {
5284
static const std::string chars =
5385
"abcdefghijklmnopqrstuvwxyz"

0 commit comments

Comments
 (0)