to be within

  • <number> [not] to be within <number> <number>

Asserts that a number is within a range.

expect(0, 'to be within', 0, 4);
expect(1, 'to be within', 0, 4);
expect(2.5, 'to be within', 0, 4);
expect(4, 'to be within', 0, 4);

In case of a failing expectation you get the following output:

expect(-1, 'to be within', 0, 4);
expected -1 to be within 0..4

This assertion can be negated using the not flag:

expect(-1, 'not to be within', 0, 4);
expect(5, 'not to be within', 0, 4);

In case of a failing expectation you get the following output:

expect(0, 'not to be within', 0, 4);
expected 0 not to be within 0..4