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

@ -167,9 +167,9 @@ pub fn check_example_evaluates_to_expected_output(
"\x1b[31mError:\x1b[0m The result of example \x1b[34m'{}'\x1b[0m for the command \x1b[34m'{}'\x1b[0m differs from the expected value.\n\n\ "\x1b[31mError:\x1b[0m The result of example \x1b[34m'{}'\x1b[0m for the command \x1b[34m'{}'\x1b[0m differs from the expected value.\n\n\
Expected: {:?}\n\ Expected: {:?}\n\
Actual: {:?}\n", Actual: {:?}\n",
example.description, example.description,
cmd_name, cmd_name,
expected, expected,
result result
); );
} }

View File

@ -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"
);
}
}

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; mod collect;