Skip to content

Commit

Permalink
slice: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trou committed Jul 9, 2024
1 parent d3f6e05 commit bbb17c4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/sliceapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,20 @@ mod tests {
.stdout(&b"\x02\x03\x04\x05\x06\x07\x08\x09"[..])
.success();

/* Should fail because "start" is before beginning of file */
assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", &tmpfile.path().to_str().unwrap(), "-200"])
.assert()
.failure();

/* Should fail because "end" is before "start */
assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", &tmpfile.path().to_str().unwrap(), "0", "-300"])
.assert()
.failure();

assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", "--", &tmpfile.path().to_str().unwrap(), "-2"])
Expand Down Expand Up @@ -376,6 +390,7 @@ mod tests {
.stdout(&b"\x02\x03\x04\x05\x06\x07\x08\x09"[..])
.success();

/* Should fail because stdin is not seekable */
assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", "-", "-2"])
Expand All @@ -384,6 +399,15 @@ mod tests {
.stdout("")
.failure();

/* Should fail because stdin is not seekable */
assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", "-", "0", "-10"])
.write_stdin(*&data)
.assert()
.stdout("")
.failure();

assert_cmd::Command::cargo_bin("rsbkb")
.expect("Could not run binary")
.args(&["slice", "-", "0", "0"])
Expand Down

0 comments on commit bbb17c4

Please sign in to comment.