1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2025-05-21 23:21:15 +02:00

feat: add string_last_position_of

This commit is contained in:
2023-12-26 20:40:46 +01:00
parent ec6e748d24
commit 1e0bf99ef6
4 changed files with 40 additions and 1 deletions

View File

@ -26,6 +26,7 @@ void string_test() {
string_starts_with_test();
string_ends_with_test();
string_position_of_test();
string_last_position_of_test();
}
void string_get_length_test() {
@ -281,6 +282,7 @@ void string_ends_with_test() {
void string_position_of_test() {
assert(string_position_of("hello world", 'e') == 2);
assert(string_position_of("hello world", 'o') == 5);
assert(string_position_of("abcdef", 'a') == 1);
assert(string_position_of("abcdef", 'b') == 2);
assert(string_position_of("abcdef", 'c') == 3);
@ -289,3 +291,15 @@ void string_position_of_test() {
assert(string_position_of("abcdef", 'f') == 6);
assert(string_position_of("abcdef", 'g') == 0);
}
void string_last_position_of_test() {
assert(string_last_position_of("hello world", 'e') == 2);
assert(string_last_position_of("hello world", 'o') == 8);
assert(string_last_position_of("abcdef", 'a') == 1);
assert(string_last_position_of("abcdef", 'b') == 2);
assert(string_last_position_of("abcdef", 'c') == 3);
assert(string_last_position_of("abcdef", 'd') == 4);
assert(string_last_position_of("abcdef", 'e') == 5);
assert(string_last_position_of("abcdef", 'f') == 6);
assert(string_last_position_of("abcdef", 'g') == 0);
}