Float/Double Assertions
An assertion tool to verify float values.
-
GdUnitFloatAssert
Function Description is_null Verifies that the current value is null. is_not_null Verifies that the current value is not null. is_equal Verifies that the current value is equal to the given one. is_not_equal Verifies that the current value is not equal to the given one. is_equal_approx Verifies that the current and expected value are approximately equal. is_less Verifies that the current value is less than the given one. is_less_equal Verifies that the current value is less than or equal the given one. is_greater Verifies that the current value is greater than the given one. is_greater_equal Verifies that the current value is greater than or equal the given one. is_negative Verifies that the current value is negative. is_not_negative Verifies that the current value is not negative. is_zero Verifies that the current value is equal to zero. is_not_zero Verifies that the current value is not equal to zero. is_in Verifies that the current value is in the given set of values. is_not_in Verifies that the current value is not in the given set of values. is_between Verifies that the current value is between the given boundaries (inclusive). -
INumberAssert<float>
Function Description IsNull Verifies that the current value is null. IsNotNull Verifies that the current value is not null. IsEqual Verifies that the current value is equal to the given one. IsNotEqual Verifies that the current value is not equal to the given one. IsEqualApprox Verifies that the current and expected value are approximately equal. IsLess Verifies that the current value is less than the given one. IsLessEqual Verifies that the current value is less than or equal the given one. IsGreater Verifies that the current value is greater than the given one. IsGreaterEqual Verifies that the current value is greater than or equal the given one. IsNegative Verifies that the current value is negative. IsNotNegative Verifies that the current value is not negative. IsZero Verifies that the current value is equal to zero. IsNotZero Verifies that the current value is not equal to zero. IsIn Verifies that the current value is in the given set of values. IsNotIn Verifies that the current value is not in the given set of values. IsNetween Verifies that the current value is between the given boundaries (inclusive).
Float Assert Examples
is_equal
Verifies that the current value is equal to the given one.
-
func assert_float(<current>).is_equal(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_equal(23.2) # this assertion fails because 23.2 are not equal to 23.4 assert_float(23.2).is_equal(23.4)
-
public static INumberAssert<double> AssertThat(<current>).IsEqual(<expected>)
// this assertion succeeds AssertThat(23.2).IsEqual(23.2); // this assertion fails because 23.2 are not equal to 23.4 AssertThat(23.2).IsEqual(23.4);
is_not_equal
Verifies that the current value is not equal to the given one.
-
func assert_float(<current>).is_not_equal(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_not_equal(23.4) # this assertion fails because 23.2 are equal to 23.2 assert_float(23.2).is_not_equal(23.2)
-
public static INumberAssert<double> AssertThat(<current>).IsNotEqual(<expected>)
// this assertion succeeds AssertThat(23.2).IsNotEqual(23.4); // this assertion fails because 23.2 are equal to 23.2 AssertThat(23.2).IsNotEqual(23.2);
is_equal_approx
Verifies that the current and expected value are approximately equal.
-
func is_equal_approx(<expected>, <approx>) -> GdUnitFloatAssert:
# this assertion succeeds assert_float(23.19).is_equal_approx(23.2, 0.01) assert_float(23.20).is_equal_approx(23.2, 0.01) assert_float(23.21).is_equal_approx(23.2, 0.01) # this assertion fails because 23.18 and 23.22 are not equal approximately to 23.2 +/- 0.01 assert_float(23.18).is_equal_approx(23.2, 0.01) assert_float(23.22).is_equal_approx(23.2, 0.01)
-
public static INumberAssert<double> AssertThat(<current>).IsEqualApprox(<expected>, <approx>)
// this assertion succeeds AssertThat(23.19).IsEqualApprox(23.2, 0.01); AssertThat(23.20).IsEqualApprox(23.2, 0.01); AssertThat(23.21).IsEqualApprox(23.2, 0.01); // this assertion fails because 23.18 and 23.22 are not equal approximately to 23.2 +/- 0.01 AssertThat(23.18).IsEqualApprox(23.2, 0.01); AssertThat(23.22).IsEqualApprox(23.2, 0.01);
is_less
Verifies that the current value is less than the given one.
-
func assert_float(<current>).is_less(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_less(23.4) assert_float(23.2).is_less(26.0) # this assertion fails because 23.2 is not less than 23.2 assert_float(23.2).is_less(23.2)
-
public static INumberAssert<double> AssertThat(<current>).IsLess(<expected>)
// this assertion succeeds AssertThat(23.2).IsLess(23.4); AssertThat(23.2).IsLess(26.0); // this assertion fails because 23.2 is not less than 23.2 AssertThat(23.2).IsLess(23.2);
is_less_equal
Verifies that the current value is less than or equal the given one.
-
func assert_float(<current>).is_less_equal(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_less_equal(23.4) assert_float(23.2).is_less_equal(23.2) # this assertion fails because 23.2 is not less than or equal to 23.1 assert_float(23.2).is_less_equal(23.1)
-
public static INumberAssert<double> AssertThat(<current>).IsLessEqual(<expected>)
// this assertion succeeds AssertThat(23.2).IsLessEqual(23.4); AssertThat(23.2).IsLessEqual(23.2); // this assertion fails because 23.2 is not less than or equal to 23.1 AssertThat(23.2).IsLessEqual(23.1);
is_greater
Verifies that the current value is greater than the given one.
-
func assert_float(<current>).is_greater(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_greater(23.0) assert_float(23.4).is_greater(22.1) # this assertion fails because 23.2 is not greater than 23.2 assert_float(23.2).is_greater(23.2)
-
public static INumberAssert<double> AssertThat(<current>).IsGreater(<expected>)
# this assertion succeeds AssertThat(23.2).IsGreater(23.0) AssertThat(23.4).IsGreater(22.1) # this assertion fails because 23.2 is not greater than 23.2 AssertThat(23.2).IsGreater(23.2)
is_greater_equal
Verifies that the current value is greater than or equal the given one.
-
func assert_float(<current>).is_greater_equal(<expected>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(23.2).is_greater_equal(20.2) assert_float(23.2).is_greater_equal(23.2) # this assertion fails because 23.2 is not greater than 23.3 assert_float(23.2).is_greater_equal(23.3)
-
public static INumberAssert<double> AssertThat(<current>).IsGreaterEqual(<expected>)
// this assertion succeeds AssertThat(23.2).IsGreaterEqual(20.2); AssertThat(23.2).IsGreaterEqual(23.2); // this assertion fails because 23.2 is not greater than 23.3 AssertThat(23.2).IsGreaterEqual(23.3);
is_negative
Verifies that the current value is negative.
-
func assert_float(<current>).is_negative() -> GdUnitFloatAssert
# this assertion succeeds assert_float(-13.2).is_negative() # this assertion fails because is not negative assert_float(13.2).is_negative()
-
public static INumberAssert<double> AssertThat(<current>).IsNegative()
// this assertion succeeds AssertThat(-13.2).IsNegative(); // this assertion fails because is not negative AssertThat(13.2).IsNegative();
is_not_negative
Verifies that the current value is not negative.
-
func assert_float(<current>).is_not_negative() -> GdUnitFloatAssert
# this assertion succeeds assert_float(13.2).is_not_negative() # this assertion fails because is negative assert_float(-13.2).is_not_negative()
-
public static INumberAssert<double> AssertThat(<current>).IsNotNegative()
// this assertion succeeds AssertThat(13.2).IsNotNegative(); // this assertion fails because is negative AssertThat(-13.2).IsNotNegative();
is_zero
Verifies that the current value is equal to zero.
-
func assert_float(<current>).is_zero() -> GdUnitFloatAssert
# this assertion succeeds assert_float(0.0).is_zero() # this assertion fail because the value is not zero assert_float(0.00001).is_zero()
-
public static INumberAssert<double> AssertThat(<current>).IsZero()
// this assertion succeeds AssertThat(0.0).IsZero(); // this assertion fail because the value is not zero AssertThat(0.00001).IsZero();
is_not_zero
Verifies that the current value is not equal to zero.
-
func assert_float(<current>).is_not_zero() -> GdUnitFloatAssert
# this assertion succeeds assert_float(0.00001).is_not_zero() # this assertion fail because the value is not zero assert_float(0.000001).is_not_zero()
-
public static INumberAssert<double> AssertThat(<current>).IsNotZero()
// this assertion succeeds AssertThat(0.00001).IsNotZero(); // this assertion fail because the value is not zero AssertThat(0.000001).IsNotZero();
is_in
Verifies that the current value is in the given set of values.
-
func assert_float(<current>).is_in(<expected> :Array) -> GdUnitFloatAssert
# this assertion succeeds assert_float(5.2).is_in([5.1, 5.2, 5.3, 5.4]) # this assertion fail because 5.5 is not in [5.1, 5.2, 5.3, 5.4] assert_float(5.5).is_in([5.1, 5.2, 5.3, 5.4])
-
public static INumberAssert<double> AssertThat(<current>).IsIn([]<expected>)
// this assertion succeeds AssertThat(5.2).IsIn(5.1, 5.2, 5.3, 5.4); // this assertion fail because 5.5 is not in [5.1, 5.2, 5.3, 5.4] AssertThat(5.5).IsIn(5.1, 5.2, 5.3, 5.4);
is_not_in
Verifies that the current value is not in the given set of values.
-
func assert_float(<current>).is_not_in(<expected> :Array) -> GdUnitFloatAssert
# this assertion succeeds assert_float(5.2).is_not_in([5.1, 5.3, 5.4]) # this assertion fail because 5.2 is not in [5.1, 5.2, 5.3, 5.4] assert_float(5.2).is_not_in([5.1, 5.2, 5.3, 5.4])
-
public static INumberAssert<double> AssertThat(<current>).IsNotIn([]<expected>)
// this assertion succeeds AssertThat(5.2).IsNotIn(5.1, 5.3, 5.4); // this assertion fail because 5.2 is not in [5.1, 5.2, 5.3, 5.4] AssertThat(5.2).IsNotIn(5.1, 5.2, 5.3, 5.4);
is_between
Verifies that the current value is between the given boundaries (inclusive).
-
func assert_float(<current>).is_between(<from>, <to>) -> GdUnitFloatAssert
# this assertion succeeds assert_float(-20.0).is_between(-20.0, 20.9) assert_float(10.0).is_between(-20.0, 20.9) assert_float(20.9).is_between(-20.0, 20.9) # this assertion fail because the value is -10.0 and not between -9 and 0 assert_float(-10.0).is_between(-9.0, 0.0)
-
public static INumberAssert<double> AssertThat(<current>).IsBetween(<from>, <to>)
// this assertion succeeds AssertThat(-20.0).IsBetween(-20.0, 20.9); AssertThat(10.0).IsBetween(-20.0, 20.9); AssertThat(20.9).IsBetween(-20.0, 20.9); // this assertion fail because the value is -10.0 and not between -9 and 0 AssertThat(-10.0).IsBetween(-9.0, 0.0);