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

Round To Precision Verify Sub
Math Reals Class

Private Sub RoundToPrecisionVerify()
    ' Test the RoundToPrecision function.

    Debug.Assert RoundToPrecision(1.9) = 2
    Debug.Assert RoundToPrecision(1.5) = 2

    Debug.Assert RoundToPrecision(1.1) = 1
    Debug.Assert RoundToPrecision(1) = 1
    Debug.Assert RoundToPrecision(0.9) = 1
    Debug.Assert RoundToPrecision(0.5) = 1

    Debug.Assert RoundToPrecision(0.1) = 0
    Debug.Assert RoundToPrecision(0) = 0
    Debug.Assert RoundToPrecision(-0.1) = 0
    Debug.Assert RoundToPrecision(-0.5) = 0

    Debug.Assert RoundToPrecision(-0.9) = -1
    Debug.Assert RoundToPrecision(-1) = -1
    Debug.Assert RoundToPrecision(-1.1) = -1
    Debug.Assert RoundToPrecision(-1.5) = -1

    Debug.Assert RoundToPrecision(-1.9) = -2

    Debug.Assert RoundToPrecision(1.27, 0.1) = 1.3
    Debug.Assert RoundToPrecision(1.27, 0.5) = 1.5
    Debug.Assert Approx(RoundToPrecision(1.23, 0.1), 1.2)
    Debug.Assert RoundToPrecision(1.23, 0.5) = 1

    Debug.Assert RoundToPrecision(123456, 10) = 123460
    Debug.Assert RoundToPrecision(123456, 1000) = 123000

    Debug.Assert IsNull(RoundToPrecision(Null, 1))
    Debug.Assert IsNull(RoundToPrecision("Joe", 1))

    Debug.Assert RoundToPrecision(1.1, Null) = 1
    Debug.Assert RoundToPrecision(1.1, "Joe") = 1

End Sub

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