mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
work around all test strings being static
This commit is contained in:
parent
bf1b597369
commit
12d35ba9f1
2 changed files with 9 additions and 11 deletions
|
@ -1521,6 +1521,8 @@ pub fn strTrim(string: RocStr) callconv(.C) RocStr {
|
|||
return RocStr.init(string.asU8ptr() + leading_bytes, new_len);
|
||||
}
|
||||
|
||||
// nonempty, large, and unique:
|
||||
|
||||
if (leading_bytes > 0) {
|
||||
var i: usize = 0;
|
||||
while (i < new_len) : (i += 1) {
|
||||
|
@ -1605,11 +1607,7 @@ const ReverseUtf8Iterator = struct {
|
|||
const cp_len = unicode.utf8ByteSequenceLength(it.bytes[i]) catch unreachable;
|
||||
const slice = it.bytes[i .. i + cp_len];
|
||||
|
||||
if (i == 0) {
|
||||
it.i = null;
|
||||
} else {
|
||||
it.i = i - 1;
|
||||
}
|
||||
it.i = if (i == 0) null else i - 1;
|
||||
|
||||
return slice;
|
||||
} else {
|
||||
|
|
|
@ -984,7 +984,7 @@ fn str_trim_empty_string() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn str_trim_blank_string() {
|
||||
fn str_trim_small_blank_string() {
|
||||
assert_evals_to!(indoc!(r#"Str.trim " ""#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
|
@ -998,18 +998,18 @@ fn str_trim_small_to_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn str_trim_large_to_large() {
|
||||
fn str_trim_large_to_large_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim " hello giant world ""#),
|
||||
RocStr::from("hello giant world"),
|
||||
indoc!(r#"Str.trim (Str.concat " " "hello world from a large string ")"#),
|
||||
RocStr::from("hello world from a large string"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str_trim_large_to_small() {
|
||||
fn str_trim_large_to_small_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim " hello world ""#),
|
||||
indoc!(r#"Str.trim (Str.concat " " "hello world ")"#),
|
||||
RocStr::from("hello world"),
|
||||
RocStr
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue