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:
raleng 2022-07-28 01:35:08 +02:00
parent 261ff3224d
commit 71e83746cc
No known key found for this signature in database
GPG key ID: A7DBF700E0E77020

View file

@ -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 {