Integer Assertions

An assertion tool to verify integer values.

  • GdUnitIntAssert

    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_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_even Verifies that the current value is even.
    is_odd Verifies that the current value is odd.
    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<int>

    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.
    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.
    IsEven Verifies that the current value is even.
    IsOdd Verifies that the current value is odd.
    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.
    IsBetween Verifies that the current value is between the given boundaries (inclusive).

Integer Assert Examples

is_equal

Verifies that the current value is equal to the given one.

  •     func assert_int(<current>).is_equal(<expected>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_equal(23)
    
        # this assertion fails because 23 are not equal to 42
        assert_int(23).is_equal(42)
    
  •     INumberAssert<int> AssertThat(<current>).IsEqual(<expected>)
    
        // this assertion succeeds
        AssertThat(23).IsEqual(23);
    
        // this assertion fails because 23 are not equal to 42
        AssertThat(23).IsEqual(42);
    

is_not_equal

Verifies that the current value is not equal to the given one.

  •     func assert_int(<current>).is_not_equal(<expected>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_not_equal(42)
    
        # this assertion fails because 23 are equal to 23 
        assert_int(23).is_not_equal(23)
    
  •     INumberAssert<int> AssertThat(<current>).IsNotEqual(<expected>)
    
        // this assertion succeeds
        AssertThat(23).IsNotEqual(42);
    
        // this assertion fails because 23 are equal to 23 
        AssertThat(23).IsNotEqual(23);
    

is_less

Verifies that the current value is less than the given one.

  •     func assert_int(<current>).is_less(<expected>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_less(42)
        assert_int(23).is_less(24)
    
        # this assertion fails because 23 is not less than 23
        assert_int(23).is_less(23)
    
  •     INumberAssert<int> AssertThat(<current>).IsLess(<expected>)
    
        // this assertion succeeds
        AssertThat(23).IsLess(42);
        AssertThat(23).IsLess(24);
    
        // this assertion fails because 23 is not less than 23
        AssertThat(23).IsLess(23);
    

is_less_equal

Verifies that the current value is less than or equal the given one.

  •     func assert_int(<current>).is_less_equal(<expected>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_less_equal(42)
        assert_int(23).is_less_equal(23)
    
        # this assertion fails because 23 is not less than or equal to 22
        assert_int(23).is_less_equal(22)
    
  •     INumberAssert<int> AssertThat(<current>).IsLessEqual(<expected>)
    
        // this assertion succeeds
        AssertThat(23).IsLessEqual(42);
        AssertThat(23).IsLessEqual(23);
    
        // this assertion fails because 23 is not less than or equal to 22
        AssertThat(23).IsLessEqual(22);
    

is_greater

Verifies that the current value is greater than the given one.

  •     func assert_int(<current>).is_greater(<expected>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_greater(20)
        assert_int(23).is_greater(22)
    
        # this assertion fails because 23 is not greater than 23
        assert_int(23).is_greater(23)
    
  •     INumberAssert<int> AssertThat(<current>).IsGreater(<expected>)
    
        // this assertion succeeds
        AssertThat(23).IsGreater(20);
        AssertThat(23).IsGreater(22);
    
        // this assertion fails because 23 is not greater than 23
        AssertThat(23).IsGreater(23);
    

is_greater_equal

Verifies that the current value is greater than or equal the given one.

  •     func assert_int(<current>).is_greater_equal(<expected>) -> GdUnitIntAssert
    
        assert_int(23).is_greater_equal(20)
        assert_int(23).is_greater_equal(23)
    
        # this assertion fails because 23 is not greater than 23
        assert_int(23).is_greater_equal(24)
    
  •     INumberAssert<int> AssertThat(<current>).IsGreaterEqual(<expected>)
    
        AssertThat(23).IsGreaterEqual(20)
        AssertThat(23).IsGreaterEqual(23)
    
        # this assertion fails because 23 is not greater than 23
        AssertThat(23).IsGreaterEqual(24)
    

is_even

Verifies that the current value is even.

  •     func assert_int(<current>).is_even() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(12).is_even()
    
        # this assertion fail because the value '13' is not even
        assert_int(13).is_even()
    
  •     INumberAssert<int> AssertThat(<current>).IsEven()
    
        // this assertion succeeds
        AssertThat(12).IsEven();
    
        // this assertion fail because the value '13' is not even
        AssertThat(13).IsEven();
    

is_odd

Verifies that the current value is odd.

  •     func assert_int(<current>).is_odd() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(13).is_odd()
    
        # this assertion fail because the value '12' is even
        assert_int(12).is_odd()
    
  •     INumberAssert<int> AssertThat(<current>).IsOdd()
    
        // this assertion succeeds
        AssertThat(13).IsOdd();
    
        // this assertion fail because the value '12' is even
        AssertThat(12).IsOdd();
    

is_negative

Verifies that the current value is negative.

  •     func assert_int(<current>).is_negative() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(-13).is_negative()
    
        # this assertion fail because the value '13' is positive
        assert_int(13).is_negative()
    
  •     INumberAssert<int> AssertThat(<current>).IsNegative()
    
        // this assertion succeeds
        AssertThat(-13).IsNegative();
    
        // this assertion fail because the value '13' is positive
        AssertThat(13).IsNegative();
    

is_not_negative

Verifies that the current value is not negative.

  •     func assert_int(<current>).is_not_negative() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(13).is_not_negative()
    
        # this assertion fail because the value '-13' is negative
        assert_int(-13).is_not_negative()
    
  •     INumberAssert<int> AssertThat(<current>).IsNotNegative()
    
        // this assertion succeeds
        AssertThat(13).IsNotNegative();
    
        // this assertion fail because the value '-13' is negative
        AssertThat(-13).IsNotNegative();
    

is_zero

Verifies that the current value is equal to zero.

  •     func assert_int(<current>).is_zero() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(0).is_zero()
    
        # this assertion fail because the value is not zero
        assert_int(1).is_zero()
    
  •     INumberAssert<int> AssertThat(<current>).IsZero()
    
        // this assertion succeeds
        AssertThat(0).IsZero();
    
        // this assertion fail because the value is not zero
        AssertThat(1).IsZero();
    

is_not_zero

Verifies that the current value is not equal to zero.

  •     func assert_int(<current>).is_not_zero() -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(1).is_not_zero()
    
        # this assertion fail because the value is zero
        assert_int(0).is_not_zero()
    
  •     INumberAssert<int> AssertThat(<current>).IsNotZero()
    
        // this assertion succeeds
        AssertThat(1).IsNotZero();
    
        // this assertion fail because the value is zero
        AssertThat(0).IsNotZero();
    

is_in

Verifies that the current value is in the given set of values.

  •     func assert_int(<current>).is_in(<expected> :Array) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(5).is_in([3, 4, 5, 6])
    
        # this assertion fail because 7 is not in [3, 4, 5, 6]
        assert_int(7).is_in([3, 4, 5, 6])
    
  •     INumberAssert<int> AssertThat(<current>).IsIn([] <expected>)
    
        // this assertion succeeds
        AssertThat(5).IsIn(3, 4, 5, 6);
    
        // this assertion fail because 7 is not in [3, 4, 5, 6]
        AssertThat(7).IsIn(3, 4, 5, 6);
    

is_not_in

Verifies that the current value is not in the given set of values.

  •     func assert_int(<current>).is_not_in(<expected> :Array) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(5).is_not_in([3, 4, 6, 7])
    
        # this assertion fail because 5 is in [3, 4, 5, 6]
        assert_int(5).is_not_in([3, 4, 5, 6])
    
  •     INumberAssert<int> AssertThat(<current>).IsNotIn([] <expected>)
    
        // this assertion succeeds
        AssertThat(5).IsNotIn(3, 4, 6, 7);
    
        // this assertion fail because 5 is in [3, 4, 5, 6]
        AssertThat(5).IsNotIn(3, 4, 5, 6);
    

is_between

Verifies that the current value is between the given boundaries (inclusive).

  •     func assert_int(<current>).is_between(<from>, <to>) -> GdUnitIntAssert
    
        # this assertion succeeds
        assert_int(23).is_between(20, 30)
        assert_int(23).is_between(23, 24)
    
        # this assertion fail because the value is zero and not between 1 and 9
        assert_int(0).is_between(1, 9)
    
  •     INumberAssert<int> AssertThat(<current>).IsBetween(<from>, <to>)
    
        // this assertion succeeds
        AssertThat(23).IsBetween(20, 30);
        AssertThat(23).IsBetween(23, 24);
    
        // this assertion fail because the value is zero and not between 1 and 9
        AssertThat(0).IsBetween(1, 9);
    

Copyright © 2021-2024 Mike Schulze. Distributed by an MIT license.