Skip to content

Commit a213272

Browse files
committed
Add tests for when '-' is used to signify to use standard input
1 parent 25e4a17 commit a213272

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/params.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,35 @@ mod tests {
457457
);
458458
}
459459
#[test]
460+
fn default_to_stdin() {
461+
assert_eq!(
462+
Ok(Params {
463+
from: os("foo"),
464+
to: os("/dev/stdin"),
465+
..Default::default()
466+
}),
467+
parse_params([os("diff"), os("foo"), os("-")].iter().cloned())
468+
);
469+
assert_eq!(
470+
Ok(Params {
471+
from: os("/dev/stdin"),
472+
to: os("bar"),
473+
..Default::default()
474+
}),
475+
parse_params([os("diff"), os("-"), os("bar")].iter().cloned())
476+
);
477+
assert_eq!(
478+
Ok(Params {
479+
from: os("/dev/stdin"),
480+
to: os("/dev/stdin"),
481+
..Default::default()
482+
}),
483+
parse_params([os("diff"), os("-"), os("-")].iter().cloned())
484+
);
485+
assert!(parse_params([os("diff"), os("foo"), os("bar"), os("-")].iter().cloned()).is_err());
486+
assert!(parse_params([os("diff"), os("-"), os("-"), os("-")].iter().cloned()).is_err());
487+
}
488+
#[test]
460489
fn unknown_argument() {
461490
assert!(
462491
parse_params([os("diff"), os("-g"), os("foo"), os("bar")].iter().cloned()).is_err()

0 commit comments

Comments
 (0)