mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
add countSegments test case
The test ensures countSegments returns a count of two when the string and the delimiter are equal. The expected result of Str.split in that case is ["", ""].
This commit is contained in:
parent
261ff3224d
commit
71e83746cc
1 changed files with 15 additions and 0 deletions
|
@ -1192,6 +1192,21 @@ test "countSegments: delimiter interspered" {
|
|||
try expectEqual(segments_count, 3);
|
||||
}
|
||||
|
||||
test "countSegments: string equals delimiter" {
|
||||
// Str.split "/" "/" == ["", ""]
|
||||
// 2 segments
|
||||
const str_delimiter_arr = "/";
|
||||
const str_delimiter = RocStr.init(str_delimiter_arr, str_delimiter_arr.len);
|
||||
|
||||
defer {
|
||||
str_delimiter.deinit();
|
||||
}
|
||||
|
||||
const segments_count = countSegments(str_delimiter, str_delimiter);
|
||||
|
||||
try expectEqual(segments_count, 2);
|
||||
}
|
||||
|
||||
// Str.countGraphemeClusters
|
||||
const grapheme = @import("helpers/grapheme.zig");
|
||||
pub fn countGraphemeClusters(string: RocStr) callconv(.C) usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue