There was an error while loading. Please reload this page.
1 parent 9d37c86 commit 873aa80Copy full SHA for 873aa80
1 file changed
rosidl_runtime_rs/src/string.rs
@@ -522,6 +522,15 @@ mod tests {
522
}
523
524
525
+ /// If we use char::arbitrary(g) then we can get back characters which are
526
+ /// outside the ASCII range. Since the length calculated by [`String`] is
527
+ /// based on the utf-8 length of the string (not based on the number of bytes
528
+ /// in the string), putting non-ASCII characters into it can skew the length
529
+ /// calculation in strange ways.
530
+ ///
531
+ /// This function generates only ASCII characters by cutting their values
532
+ /// off at 127. This does not give an even distribution of ASCII characters,
533
+ /// but that fact is not important for this smoke test.
534
fn generate_ascii(g: &mut Gen) -> char {
535
let c = u8::min(u8::arbitrary(g), 127);
536
c as char
0 commit comments