<-- Previous || Up || Next -->

Ceiling Verify Sub
Math Reals Class

Private Sub CeilingVerify()
    ' Test the Ceiling function.

    ' Precision = .5

    Debug.Assert Ceiling(1.4, 0.5) = 1.5
    Debug.Assert Ceiling(1.1, 0.5) = 1.5

    Debug.Assert Ceiling(1, 0.5) = 1
    Debug.Assert Ceiling(0.9, 0.5) = 1
    Debug.Assert Ceiling(0.6, 0.5) = 1
    
    Debug.Assert Ceiling(0.5, 0.5) = 0.5
    Debug.Assert Ceiling(0.4, 0.5) = 0.5
    Debug.Assert Ceiling(0.1, 0.5) = 0.5
    
    Debug.Assert Ceiling(0, 0.5) = 0
    Debug.Assert Ceiling(-0.1, 0.5) = 0
    Debug.Assert Ceiling(-0.4, 0.5) = 0

    Debug.Assert Ceiling(-0.5, 0.5) = -0.5
    Debug.Assert Ceiling(-0.6, 0.5) = -0.5
    Debug.Assert Ceiling(-0.9, 0.5) = -0.5

    Debug.Assert Ceiling(-1, 0.5) = -1
    Debug.Assert Ceiling(-1.1, 0.5) = -1
    Debug.Assert Ceiling(-1.4, 0.5) = -1

    ' Precision = 1

    Debug.Assert Ceiling(2.9) = 3
    Debug.Assert Ceiling(2.1) = 3
    
    Debug.Assert Ceiling(2) = 2
    Debug.Assert Ceiling(1.9) = 2
    Debug.Assert Ceiling(1.1) = 2
    
    Debug.Assert Ceiling(1) = 1
    Debug.Assert Ceiling(0.9) = 1
    Debug.Assert Ceiling(0.1) = 1
    
    Debug.Assert Ceiling(0) = 0
    Debug.Assert Ceiling(-0.1) = 0
    Debug.Assert Ceiling(-0.9) = 0
    
    Debug.Assert Ceiling(-1) = -1
    Debug.Assert Ceiling(-1.1) = -1
    Debug.Assert Ceiling(-1.9) = -1

    Debug.Assert Ceiling(-2) = -2
    Debug.Assert Ceiling(-2.1) = -2
    Debug.Assert Ceiling(-2.9) = -2

    ' Precision = 2

    Debug.Assert Ceiling(5.9, 2) = 6
    Debug.Assert Ceiling(4.1, 2) = 6
    
    Debug.Assert Ceiling(4, 2) = 4
    Debug.Assert Ceiling(3.9, 2) = 4
    Debug.Assert Ceiling(2.1, 2) = 4
    
    Debug.Assert Ceiling(2, 2) = 2
    Debug.Assert Ceiling(1.9, 2) = 2
    Debug.Assert Ceiling(0.1, 2) = 2
    
    Debug.Assert Ceiling(0, 2) = 0
    Debug.Assert Ceiling(-0.1, 2) = 0
    Debug.Assert Ceiling(-1.9, 2) = 0
    
    Debug.Assert Ceiling(-2, 2) = -2
    Debug.Assert Ceiling(-2.1, 2) = -2
    Debug.Assert Ceiling(-3.9, 2) = -2

    Debug.Assert Ceiling(-4, 2) = -4
    Debug.Assert Ceiling(-4.1, 2) = -4
    Debug.Assert Ceiling(-5.9, 2) = -4

    ' Other

    Debug.Assert IsNull(Ceiling(Null))
    Debug.Assert IsNull(Ceiling("Joe"))

    Debug.Assert Ceiling(2.1, Null) = 3
    Debug.Assert Ceiling(2.1, "Joe") = 3

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.