1
0
mirror of https://github.com/nushell/nushell.git synced 2024-12-12 02:02:32 +01:00
nushell/crates/nu-command/tests/commands/math/avg.rs
Stefan Holderbach 656f707a0b
Clean up tests containing unnecessary cwd: tokens ()
# Description
The working directory doesn't have to be set for those tests (or would
be the default anyways). When appropriate also remove calls to the
`pipeline()` function. In most places kept the diff minimal and only
removed the superfluous part to not pollute the blame view. With simpler
tests also simplified things to make them more readable overall (this
included removal of the raw string literal).

Work for 
2023-07-17 18:43:51 +02:00

23 lines
493 B
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn can_average_numbers() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sgml_description.json
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
| math avg
"#
));
assert_eq!(actual.out, "101.5")
}
#[test]
fn can_average_bytes() {
let actual = nu!("[100kb, 10b, 100mib] | math avg | to json -r");
assert_eq!(actual.out, "34985870");
}