Skip to content

Commit b64183b

Browse files
cakebakerBenWiederhake
authored andcommitted
fmt: use "unwrap()" instead of "?" in tests
1 parent 263f4a0 commit b64183b

1 file changed

Lines changed: 18 additions & 26 deletions

File tree

src/uu/fmt/src/fmt.rs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -470,62 +470,54 @@ pub fn uu_app() -> Command {
470470

471471
#[cfg(test)]
472472
mod tests {
473-
use std::error::Error;
474-
475473
use crate::uu_app;
476474
use crate::{extract_files, extract_width};
477475

478476
#[test]
479-
fn parse_negative_width() -> Result<(), Box<dyn Error>> {
480-
let matches = uu_app().try_get_matches_from(vec!["fmt", "-3", "some-file"])?;
477+
fn parse_negative_width() {
478+
let matches = uu_app()
479+
.try_get_matches_from(vec!["fmt", "-3", "some-file"])
480+
.unwrap();
481481

482482
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
483-
484483
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
485-
486-
Ok(())
487484
}
488485

489486
#[test]
490-
fn parse_width_as_arg() -> Result<(), Box<dyn Error>> {
491-
let matches = uu_app().try_get_matches_from(vec!["fmt", "-w3", "some-file"])?;
487+
fn parse_width_as_arg() {
488+
let matches = uu_app()
489+
.try_get_matches_from(vec!["fmt", "-w3", "some-file"])
490+
.unwrap();
492491

493492
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
494-
495493
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
496-
497-
Ok(())
498494
}
499495

500496
#[test]
501-
fn parse_no_args() -> Result<(), Box<dyn Error>> {
502-
let matches = uu_app().try_get_matches_from(vec!["fmt"])?;
497+
fn parse_no_args() {
498+
let matches = uu_app().try_get_matches_from(vec!["fmt"]).unwrap();
503499

504500
assert_eq!(extract_files(&matches).unwrap(), vec!["-"]);
505-
506501
assert_eq!(extract_width(&matches).ok(), Some(None));
507-
508-
Ok(())
509502
}
510503

511504
#[test]
512-
fn parse_just_file_name() -> Result<(), Box<dyn Error>> {
513-
let matches = uu_app().try_get_matches_from(vec!["fmt", "some-file"])?;
505+
fn parse_just_file_name() {
506+
let matches = uu_app()
507+
.try_get_matches_from(vec!["fmt", "some-file"])
508+
.unwrap();
514509

515510
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
516-
517511
assert_eq!(extract_width(&matches).ok(), Some(None));
518-
519-
Ok(())
520512
}
521513

522514
#[test]
523-
fn parse_with_both_widths_positional_first() -> Result<(), Box<dyn Error>> {
524-
let matches = uu_app().try_get_matches_from(vec!["fmt", "-10", "-w3", "some-file"])?;
515+
fn parse_with_both_widths_positional_first() {
516+
let matches = uu_app()
517+
.try_get_matches_from(vec!["fmt", "-10", "-w3", "some-file"])
518+
.unwrap();
525519

526520
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
527-
528521
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
529-
Ok(())
530522
}
531523
}

0 commit comments

Comments
 (0)