Requested changes

This commit is contained in:
Simon Curtis
2024-10-23 19:24:34 +00:00
committed by Simon Curtis
parent b99d8c1016
commit 82c2ae1cfd
4 changed files with 24 additions and 34 deletions

View File

@ -237,35 +237,3 @@ fn read_stream(
PipelineData::ByteStream(stream, metadata)
}
#[cfg(test)]
mod tests {
use super::*;
use nu_test_support::nu;
#[test]
fn test_examples() {
use crate::test_examples;
test_examples(BytesAt {})
}
#[test]
fn returns_error_for_relative_range_on_infinite_stream() {
let actual = nu!("nu --testbin iecho 3 | bytes at ..-3");
assert!(
actual.err.contains(
"Negative range values cannot be used with streams that don't specify a length"
),
"Expected error message for negative range with infinite stream"
);
}
#[test]
fn returns_bytes_for_fixed_range_on_infinite_stream() {
let actual = nu!("nu --testbin iecho 3 | bytes at ..10 | decode");
assert_eq!(
actual.out, "33333",
"Expected bytes from index 1 to 10, but got different output"
);
}
}

View File

@ -0,0 +1,21 @@
use nu_test_support::nu;
#[test]
fn returns_error_for_relative_range_on_infinite_stream() {
let actual = nu!("nu --testbin iecho 3 | bytes at ..-3");
assert!(
actual.err.contains(
"Negative range values cannot be used with streams that don't specify a length"
),
"Expected error message for negative range with infinite stream"
);
}
#[test]
fn returns_bytes_for_fixed_range_on_infinite_stream() {
let actual = nu!("nu --testbin iecho 3 | bytes at ..10 | decode");
assert_eq!(
actual.out, "33333",
"Expected bytes from index 1 to 10, but got different output"
);
}

View File

@ -1 +1,2 @@
mod at;
mod collect;