assertInRange

throws AssertError if tested value out of range

for RANGETYPE allows values: "[]", "(]", "[)", "()"

void
assertInRange
(
string RANGETYPE = "[)"
MIN
V
MAX
string file = __FILE__
size_t line = __LINE__
)
(
in MIN min_value
,,
in MAX max_value
,
lazy string fmt = "assertInRange fails: %s is out of %s"
)
if (
is(typeof(min_value < tested_value)) &&
is(typeof(tested_value < max_value))
)

Examples

assertInRange( 0, 1, 2 );
assertInRange( 0, 0, 2 );
assertInRange!"[]"( 0, 2, 2 );
assertInRange!"(]"( 0.0f, 2, 2.0 );

Meta