Added unit tests for String data type and updated CI

This commit is contained in:
2026-01-08 16:29:34 +01:00
parent 3b7e2dabc9
commit 44e3dfa58d
5 changed files with 171 additions and 7 deletions

View File

@@ -451,13 +451,20 @@ string_result_t string_set_at(string_t *str, size_t position, const char *utf8_c
int new_len;
if (str == NULL || position >= str->char_count || utf8_is_char_valid(utf8_char, &new_len) == 0) {
if (str == NULL || utf8_is_char_valid(utf8_char, &new_len) == 0) {
result.status = STRING_ERR_INVALID;
SET_MSG(result, "Invalid index or character");
return result;
}
if (position >= str->char_count) {
result.status = STRING_ERR_OVERFLOW;
SET_MSG(result, "Index out of bounds");
return result;
}
char *pos = str->data;
for (size_t idx = 0; idx < position; idx++) {
pos += utf8_char_len((unsigned char)*pos);