mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
add zig test cases
This commit is contained in:
parent
6f7a26895a
commit
e21fa3cb0a
1 changed files with 41 additions and 5 deletions
|
@ -1666,10 +1666,18 @@ test "strTrim: empty" {
|
|||
try expect(trimmedEmpty.eq(RocStr.empty()));
|
||||
}
|
||||
|
||||
test "strTrim: blank" {
|
||||
const original_bytes = " ";
|
||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||
defer original.deinit();
|
||||
|
||||
const trimmed = strTrim(original);
|
||||
|
||||
try expect(trimmed.eq(RocStr.empty()));
|
||||
}
|
||||
|
||||
// TODO GIESCH
|
||||
// ask how to manually mess with refcount, to unit test the shared case
|
||||
// TODO GIESCH
|
||||
// unit tests for small cases
|
||||
test "strTrim: large to large" {
|
||||
const original_bytes = " hello world world ";
|
||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||
|
@ -1688,14 +1696,42 @@ test "strTrim: large to large" {
|
|||
try expect(trimmed.eq(expected));
|
||||
}
|
||||
|
||||
test "strTrim: blank" {
|
||||
const original_bytes = " ";
|
||||
// TODO GIESCH
|
||||
// is this test correct? would expect still 'large' after
|
||||
test "strTrim: large to small" {
|
||||
const original_bytes = " hello world ";
|
||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||
defer original.deinit();
|
||||
|
||||
try expect(!original.isSmallStr());
|
||||
|
||||
const expected_bytes = "hello world";
|
||||
const expected = RocStr.init(expected_bytes, expected_bytes.len);
|
||||
defer expected.deinit();
|
||||
|
||||
try expect(expected.isSmallStr());
|
||||
|
||||
const trimmed = strTrim(original);
|
||||
|
||||
try expect(trimmed.eq(RocStr.empty()));
|
||||
try expect(trimmed.eq(expected));
|
||||
}
|
||||
|
||||
test "strTrim: small to small" {
|
||||
const original_bytes = " hello world ";
|
||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||
defer original.deinit();
|
||||
|
||||
try expect(original.isSmallStr());
|
||||
|
||||
const expected_bytes = "hello world";
|
||||
const expected = RocStr.init(expected_bytes, expected_bytes.len);
|
||||
defer expected.deinit();
|
||||
|
||||
try expect(expected.isSmallStr());
|
||||
|
||||
const trimmed = strTrim(original);
|
||||
|
||||
try expect(trimmed.eq(expected));
|
||||
}
|
||||
|
||||
test "ReverseUtf8View: hello world" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue