Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Panic when diff between actual and expected output adds a new line at the beginning of the output #112

Closed
livioribeiro opened this issue Jun 6, 2018 · 0 comments

Comments

@livioribeiro
Copy link

  • assert_cli version: 0.6.1
  • Rust version: 1.26.1
  • OS and version: Ubuntu 18.04

When comparing the actual output with the expected output, if a new line is added at the beginning of the output, the following panic happens:

failures:

---- test stdout ----
	thread 'test' panicked at 'attempt to subtract with overflow', ~/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/assert_cli-0.6.1/src/diff.rs:18:29

The problem happens at line:

match diffs[i - 1] {

If i is 0, meaning that the diff is an addition to the first line, the panic happens.

For example, consider the code:

const EXPECTED: &str = "Line 1\nLine 2\nLine 3";
Assert::main_binary()
        .with_args(&args)
        .succeeds()
        .and().stdout().is(EXPECTED)

If the output is Line 0\nLine 1\nLine 2\n Line 3 (Line 0 added at the beginning) , the panic happens.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants