Skip to content

Add doc tests to Panic documentation #11

@killercup

Description

@killercup

We recently added these docs:

a-range/src/lib.rs

Lines 54 to 58 in ce391ed

/// Construct a [Range] that counts up to the given item.
///
/// # Panics
///
/// This function will panic when trying to create a [Range] where the upper bound is less than the lower bound.

This behavior is tested in this unit test:

a-range/src/lib.rs

Lines 393 to 397 in ce391ed

#[test]
#[should_panic]
fn fail_up_to_invalid_range() {
from(40).up_to(39);
}

It is also possible for this to become a doc test (as I've just found out), which would make this more visible.

  • Turn fail_up_to_invalid_range and fail_down_to_invalid_range tests into doc tests

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions