Skip to content

Add IsBetween for char #1053

Description

@vbreuss

char implements IComparable<char>, but ThatChar has no range expectation. Ranges without a named BCL counterpart currently require .Satisfies(c => c is >= 'Ѐ' and <= 'ӿ'), which produces a poor failure message, and IsOneOf is impractical for contiguous ranges.

Use cases not covered by the existing expectations:

  • Unicode block membership (e.g. Cyrillic 'Ѐ'..'ӿ') or a custom alphabet
  • Contiguous ranges too large to enumerate with IsOneOf ('a'..'z' is 26 arguments, and IsALetter() is Unicode-wide so it means something different)

Proposed API

Mirrors ThatTimeSpan.IsBetween:

await Expect.That(subject).IsBetween('a').And('z');

Deliberately not adding IsGreaterThan / IsLessThan etc.: the concrete cases for those (ASCII digit, hex digit, upper/lower case) are better served by named predicates — see the companion issue — and comparison operators on char read poorly in failure messages. No .Within() tolerance overloads.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions