mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 13:27:47 +02:00
Requested changes
This commit is contained in:
committed by
Simon Curtis
parent
b99d8c1016
commit
82c2ae1cfd
@ -237,35 +237,3 @@ fn read_stream(
|
|||||||
|
|
||||||
PipelineData::ByteStream(stream, metadata)
|
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"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
21
crates/nu-command/tests/commands/bytes/at.rs
Normal file
21
crates/nu-command/tests/commands/bytes/at.rs
Normal 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"
|
||||||
|
);
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
|
mod at;
|
||||||
mod collect;
|
mod collect;
|
||||||
|
Reference in New Issue
Block a user