Skip to content

Assert the result of the conversion tests - #213

Merged
jdno merged 1 commit into
mainfrom
assert-conversion-results
Aug 21, 2026
Merged

jdno merged 1 commit into
mainfrom
assert-conversion-results

Conversation

@jdno

@jdno jdno commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Thirteen tests bound their result to a discarded variable and asserted nothing:

#[test]
fn from_str_returns_name() {
    let _name: TestName = "test".into();
}

That proves the conversion compiles and nothing else. A conversion that returned the wrong value passed, and the name promised a result the test never checked. AGENTS.md also asks that each test hold exactly one assertion, and these held none.

Each test now asserts the value it produces:

#[test]
fn from_str_returns_name() {
    let name: TestName = "test".into();

    assert_eq!("test", name.get());
}

Notes for review

  • Affects From<&str>, From<String>, From<i64>, TryFrom<&str> and TryFrom<String> across all seven test files.
  • Verified the assertions actually fire, by changing an expected value and confirming the tests fail. They did not fail before this change.
  • The duplicate conversion in tests/secret.rs, where from_string_returns_secret converts from a &str, is left alone here and fixed separately.

just pre-commit passes.

Thirteen tests bound their result to a discarded variable and asserted
nothing, so they proved only that the conversion compiles. A conversion
that returned the wrong value passed them, and their names promised a
result they never checked.

Each now asserts the value it produces. Confirmed by changing an
expected value and watching the tests fail, which they did not do
before.
@jdno
jdno merged commit 1939a91 into main Aug 21, 2026
22 checks passed
@jdno
jdno deleted the assert-conversion-results branch August 21, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant