Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/basenc/src/basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn uu_app() -> Command {
}

fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args.collect_lossy())?;
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

let encodings = get_encodings();
let format = encodings
Expand Down
30 changes: 29 additions & 1 deletion tests/by-util/test_basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// spell-checker: ignore (encodings) lsbf msbf

use uutests::new_ucmd;
use uutests::{at_and_ucmd, new_ucmd};

#[test]
fn test_z85_not_padded_decode() {
Expand Down Expand Up @@ -270,3 +270,31 @@ fn test_z85_length_check() {
.succeeds()
.stdout_only("12345678");
}

#[test]
fn test_file() {
let (at, mut ucmd) = at_and_ucmd!();
let filename = "file";

at.write(filename, "foo");

ucmd.arg(filename)
.arg("--base64")
.succeeds()
.stdout_is("Zm9v\n");
}

#[test]
#[cfg(target_os = "linux")]
fn test_file_with_non_utf8_name() {
use std::os::unix::ffi::OsStringExt;
let (at, mut ucmd) = at_and_ucmd!();

let filename = std::ffi::OsString::from_vec(vec![0xFF, 0xFE]);
std::fs::write(at.plus(&filename), b"foo").unwrap();

ucmd.arg(filename)
.arg("--base64")
.succeeds()
.stdout_is("Zm9v\n");
}
Loading