Add string functions :

* string_it_get_pos to return the position in the steam
* string_it_pos to start iterating from a given position.
This commit is contained in:
Patrick Pelissier committed 2022-09-10 16:16:13 +02:00
1 parent cfeedf19f8
commit 41c4f5fe5c
2 files changed
+69 -9

No files matched your search

+8
View File
@@ -84,6 +84,7 @@ static void test_utf8_it(void)
string_init(s);
string_it_end(it2, s);
assert( string_it_get_pos(it2) == 0);
for(string_it(it, s) ; !string_end_p(it); string_next(it)) {
assert(0); // Shall not be called
@@ -98,6 +99,13 @@ static void test_utf8_it(void)
assert (i < 5);
assert (string_get_cref(it) == tab[i]);
}
assert(i == 5);
assert( string_it_get_pos(it) == 9);
string_it_pos(it2, s, 9);
assert( string_end_p(it2) );
string_it_pos(it2, s, 0);
assert( !string_end_p(it2) );
assert( string_get_cref(it2) == 45);
string_set_str (s, "H€llo René Chaînôr¬");
assert(string_length_u(s) == 19);