mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Fix 9156 endian consistency (#9873)
- fixed #9156 # Description I'm trying to fix the problems mentioned in the issue. It's my first attempt in Rust. Please let me know if there are any problems. # User-Facing Changes - The `--little-endian` option dropped, replaced with `--endian`. - Add the `--compact` option to the `into binary` command. - `into int` accepts binary input
This commit is contained in:
25
crates/nu-command/tests/commands/conversions/into/int.rs
Normal file
25
crates/nu-command/tests/commands/conversions/into/int.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn convert_back_and_forth() {
|
||||
let actual = nu!(r#"1 | into binary | into int"#);
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_into_int_little_endian() {
|
||||
let actual = nu!(r#"0x[01 00 00 00 00 00 00 00] | into int --endian little"#);
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(r#"0x[00 00 00 00 00 00 00 01] | into int --endian little"#);
|
||||
assert_eq!(actual.out, "72057594037927936");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_into_int_big_endian() {
|
||||
let actual = nu!(r#"0x[00 00 00 00 00 00 00 01] | into int --endian big"#);
|
||||
assert_eq!(actual.out, "1");
|
||||
|
||||
let actual = nu!(r#"0x[01 00 00 00 00 00 00 00] | into int --endian big"#);
|
||||
assert_eq!(actual.out, "72057594037927936");
|
||||
}
|
1
crates/nu-command/tests/commands/conversions/into/mod.rs
Normal file
1
crates/nu-command/tests/commands/conversions/into/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod int;
|
1
crates/nu-command/tests/commands/conversions/mod.rs
Normal file
1
crates/nu-command/tests/commands/conversions/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod into;
|
@ -8,6 +8,7 @@ mod cal;
|
||||
mod cd;
|
||||
mod compact;
|
||||
mod continue_;
|
||||
mod conversions;
|
||||
mod cp;
|
||||
mod date;
|
||||
mod def;
|
||||
|
@ -8,7 +8,7 @@ fn binary_skip() {
|
||||
open sample_data.ods --raw |
|
||||
skip 2 |
|
||||
take 2 |
|
||||
into int
|
||||
into int --endian big
|
||||
"#
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user