summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hofstetter <daniel.hofstetter@42dh.com>2024-05-07 09:24:05 +0200
committerBen Wiederhake <BenWiederhake.GitHub@gmx.de>2024-05-07 20:20:59 +0200
commitb64183b0de7cc7e91976f6e5ee86dac9d99fbec3 (patch)
tree475c3ec03989290a179ee91d2bce824b40a7736e
parent263f4a03776fe091e1e533ab00bde7f6f544e11c (diff)
fmt: use "unwrap()" instead of "?" in tests
-rw-r--r--src/uu/fmt/src/fmt.rs44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs
index 86d4573b0..77858b041 100644
--- a/src/uu/fmt/src/fmt.rs
+++ b/src/uu/fmt/src/fmt.rs
@@ -470,62 +470,54 @@ pub fn uu_app() -> Command {
#[cfg(test)]
mod tests {
- use std::error::Error;
-
use crate::uu_app;
use crate::{extract_files, extract_width};
#[test]
- fn parse_negative_width() -> Result<(), Box<dyn Error>> {
- let matches = uu_app().try_get_matches_from(vec!["fmt", "-3", "some-file"])?;
+ fn parse_negative_width() {
+ let matches = uu_app()
+ .try_get_matches_from(vec!["fmt", "-3", "some-file"])
+ .unwrap();
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
-
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
-
- Ok(())
}
#[test]
- fn parse_width_as_arg() -> Result<(), Box<dyn Error>> {
- let matches = uu_app().try_get_matches_from(vec!["fmt", "-w3", "some-file"])?;
+ fn parse_width_as_arg() {
+ let matches = uu_app()
+ .try_get_matches_from(vec!["fmt", "-w3", "some-file"])
+ .unwrap();
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
-
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
-
- Ok(())
}
#[test]
- fn parse_no_args() -> Result<(), Box<dyn Error>> {
- let matches = uu_app().try_get_matches_from(vec!["fmt"])?;
+ fn parse_no_args() {
+ let matches = uu_app().try_get_matches_from(vec!["fmt"]).unwrap();
assert_eq!(extract_files(&matches).unwrap(), vec!["-"]);
-
assert_eq!(extract_width(&matches).ok(), Some(None));
-
- Ok(())
}
#[test]
- fn parse_just_file_name() -> Result<(), Box<dyn Error>> {
- let matches = uu_app().try_get_matches_from(vec!["fmt", "some-file"])?;
+ fn parse_just_file_name() {
+ let matches = uu_app()
+ .try_get_matches_from(vec!["fmt", "some-file"])
+ .unwrap();
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
-
assert_eq!(extract_width(&matches).ok(), Some(None));
-
- Ok(())
}
#[test]
- fn parse_with_both_widths_positional_first() -> Result<(), Box<dyn Error>> {
- let matches = uu_app().try_get_matches_from(vec!["fmt", "-10", "-w3", "some-file"])?;
+ fn parse_with_both_widths_positional_first() {
+ let matches = uu_app()
+ .try_get_matches_from(vec!["fmt", "-10", "-w3", "some-file"])
+ .unwrap();
assert_eq!(extract_files(&matches).unwrap(), vec!["some-file"]);
-
assert_eq!(extract_width(&matches).ok(), Some(Some(3)));
- Ok(())
}
}