-
Notifications
You must be signed in to change notification settings - Fork 53
Numeric types
The following checks are available for numeric types: int, long, double, decimal, float, short, byte, uint, ulong, ushort, sbyte
Checks that the sut is zero, fails otherwise.
// This check succeeds
Check.That(0).IsZero();
// This check fails
Check.That(1).IsZero();
Checks that the sut is not zero, fails otherwise.
// This check succeeds
Check.That(1).IsNotZero();
// This check fails
Check.That(0).IsNotZero();
Checks that the sut is 0 or more, fails otherwise.
// This check succeeds
Check.That(1).IsPositiveOrZero();
// This check fails
Check.That(-1).IsPositiveOrZero();
Checks that the sut is more than 0, fails otherwise.
// This check succeeds
Check.That(1).IsStrictlyPositive();
// This check fails
Check.That(0).IsStrictlyPositive();
Checks that the sut is 0 or less, fails otherwise.
// This check succeeds
Check.That(-1).IsNegativeOrZero();
// This check fails
Check.That(1).IsNegativeOrZero();
Checks that the sut is negative, fails otherwise.
// This check succeeds
Check.That(-1).IsStrictlyNegative();
// This check fails
Check.That(1).IsStrictlyNegative();
Checks that the sut is greater than the expected value, fails if less or same.
// This check succeeds
Check.That(-1).IsStrictlyGreaterThan(-5);
// This check fails
Check.That(-1).IsStrictlyGreaterThan(0);
Checks that the sut is less than the expected value, fails if greater or same.
// This check succeeds
Check.That(-1).IsStrictlyLessThan(0);
// This check fails
Check.That(-1).IsStrictlyLessThan(-5);
Checks that the sut has a value close to expected, such as Math.Abs(expected-sut)<=tolerance, fails otherwise.
// This check succeeds
Check.That(1.1).IsCloseTo(1, .2);
// This check fails
Check.That(1.3).IsCloseTo(1, .2);
Checks that the sut is a finite number, fails otherwise.
// This check succeeds
Check.That(1.0).IsFinite();
// This check fails
Check.That(1.0/0).IsFinite();
Checks that the sut is NotANumber, fails otherwise.
// This check succeeds
Check.That(0.0/0).IsNan();
// This check fails
Check.That(0.0).IsNan();
- Welcome
- How to start
- Customising error messages
-
Check.That
- All (Equality, Type)
- Reference types
- Members based
- IEnumerable (Properties, Content, Elements)
- String (Properties, Content, RegExp )
- Numeric Type(Properties, Comparisons, Floating)
- Dictionary
- Char (Properties, Value)
- IComparable
- DateTime
- DateTimeOffset
- Misc: Boolean, TimeSpan, Stream, Enum, EventWaitHandle
- Check.ThatCode
- Check.ThatDynamic
- Extensibility
- Auxiliary types (TimeUnit)
- Mocks