Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line iterator: Improve test functions #316

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

qknogxxb
Copy link
Contributor

@niklasmohrin
As you mentioned in #314, I improved test functions on LineIterator.
With your counter example code:

let mut previous = 0;
if let Err(e) = Read::bytes(&mut self.reader)
    .find(|b| {
        let res = previous == b'\n';
        previous = *b.as_ref().unwrap();
        res
    })
    .transpose()

The test function will fail:

❯ cargo test test_first_line
   Compiling tealdeer v1.6.1 (/home/potato/repos/tealdeer)
    Finished test [unoptimized + debuginfo] target(s) in 2.76s
     Running unittests src/main.rs (target/debug/deps/tldr-8d4cf65b28f436c9)

running 2 tests
test line_iterator::test::test_first_line_old_format ... ok
test line_iterator::test::test_first_line_new_format ... FAILED

failures:

---- line_iterator::test::test_first_line_new_format stdout ----
thread 'line_iterator::test::test_first_line_new_format' panicked at 'assertion failed: `(left == right)`
  left: `ExampleCode("Description")`,
 right: `Description("Description")`', src/line_iterator.rs:122:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    line_iterator::test::test_first_line_new_format

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 14 filtered out; finished in 0.00s

error: test failed, to rerun pass `--bin tldr`

Do you think this is good enough? Or you have another idea?

@qknogxxb
Copy link
Contributor Author

And... It's wired that I didn't find any specific .md located in my ~/.cache/tealdeer/tldr-pages is a "new format". In other words, they are all "old format", which means that my contribution code will never run. Anyway, this has nothing to do with this PR, I just mention this here.

@niklasmohrin
Copy link
Collaborator

Yeah, I am not exactly sure what the idea between old and new format is or if there are any plans for migrating towards one or another. I think we talked about this some time ago, the info is probably buried in some comment somewhere. @dbrgn Do you remember what that was about?

@dbrgn
Copy link
Collaborator

dbrgn commented Mar 5, 2023

Support for the new format was added here: #32

See discussion at tldr-pages/tldr#958

From what I can tell, the new format was never accepted. So I guess we could remove it from tealdeer as well...

@niklasmohrin
Copy link
Collaborator

Well, thanks for the contribution anyways :)

@niklasmohrin niklasmohrin merged commit 8c6754a into tealdeer-rs:main Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants