Consistently triggering null pointer bug

This commit is contained in:
Joshua Hoeflich 2021-08-10 10:51:15 -05:00
parent 945212db28
commit 05d87314e7
2 changed files with 61 additions and 7 deletions

View file

@ -896,7 +896,7 @@ fn str_from_utf8_range_order_does_not_matter() {
}
#[test]
fn str_from_utf8_range_out_of_bounds() {
fn str_from_utf8_range_out_of_bounds_start_value() {
assert_evals_to!(
indoc!(
r#"
@ -911,3 +911,37 @@ fn str_from_utf8_range_out_of_bounds() {
RocStr
);
}
#[test]
fn str_from_utf8_range_count_too_high() {
assert_evals_to!(
indoc!(
r#"
bytes = Str.toUtf8 "hello"
when Str.fromUtf8Range bytes { start: 0, count: 6 } is
Ok _ -> ""
Err (BadUtf8 _ _) -> ""
Err OutOfBounds -> "out of bounds"
"#
),
RocStr::from("out of bounds"),
RocStr
);
}
#[test]
fn str_from_utf8_range_count_too_high_for_start() {
assert_evals_to!(
indoc!(
r#"
bytes = Str.toUtf8 "hello"
when Str.fromUtf8Range bytes { start: 4, count: 3 } is
Ok _ -> ""
Err (BadUtf8 _ _) -> ""
Err OutOfBounds -> "out of bounds"
"#
),
RocStr::from("out of bounds"),
RocStr
);
}