mirror of
https://github.com/theoludwig/libcproject.git
synced 2025-05-21 23:21:15 +02:00
feat: add string_position_of
This commit is contained in:
@ -25,6 +25,7 @@ void string_test() {
|
||||
string_get_last_occurence_of_character_test();
|
||||
string_starts_with_test();
|
||||
string_ends_with_test();
|
||||
string_position_of_test();
|
||||
}
|
||||
|
||||
void string_get_length_test() {
|
||||
@ -277,3 +278,14 @@ void string_ends_with_test() {
|
||||
assert(!string_ends_with("abcdef", "bcd"));
|
||||
assert(!string_ends_with("abcdef", "abcdefg"));
|
||||
}
|
||||
|
||||
void string_position_of_test() {
|
||||
assert(string_position_of("hello world", 'e') == 2);
|
||||
assert(string_position_of("abcdef", 'a') == 1);
|
||||
assert(string_position_of("abcdef", 'b') == 2);
|
||||
assert(string_position_of("abcdef", 'c') == 3);
|
||||
assert(string_position_of("abcdef", 'd') == 4);
|
||||
assert(string_position_of("abcdef", 'e') == 5);
|
||||
assert(string_position_of("abcdef", 'f') == 6);
|
||||
assert(string_position_of("abcdef", 'g') == 0);
|
||||
}
|
||||
|
@ -58,4 +58,6 @@ void string_starts_with_test();
|
||||
|
||||
void string_ends_with_test();
|
||||
|
||||
void string_position_of_test();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user