f702aea4b1
like Benoît recommended in https://lists.gambas-basic.org/pipermail/user/2018-April/063734.html
122 lines
1.8 KiB
Text
122 lines
1.8 KiB
Text
' Gambas class file
|
|
|
|
'' Name of this class has to start with d8e8fca2dc0f896fd7cb4cb0031ba249 to signal that its an internal test
|
|
|
|
Inherits UnitTest
|
|
|
|
' Signal, that this is a selftest
|
|
Public Const constDegUnittestSelftest As Boolean = True
|
|
|
|
Public Sub TestAssert()
|
|
|
|
Me.R.Assert("True", "Shall be True")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEmpty()
|
|
|
|
Dim s As String = ""
|
|
|
|
Me.R.AssertEmpty(s, "Shall be Empty")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsFloat()
|
|
|
|
Dim f As Float
|
|
|
|
f = 0.55555555555555
|
|
|
|
Me.R.AssertEqualsFloat(f, 0.55555555555555, 0, "Float equal")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsLong()
|
|
|
|
Dim l As Long
|
|
|
|
l = 5555555555555555
|
|
|
|
Me.R.AssertEqualsLong(5555555555555555, l, "Long equal")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsDate()
|
|
|
|
Dim d As Date
|
|
|
|
d = Now()
|
|
|
|
Me.R.AssertEqualsDate(d, d, "Date equal")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsObject()
|
|
|
|
Dim s As New TestCase("1", Me)
|
|
Dim s2 As Object
|
|
|
|
s2 = s
|
|
|
|
Me.R.AssertEqualsObject(s2, s)
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsString()
|
|
|
|
Dim s1, s2 As String
|
|
|
|
s1 = "blaahhh"
|
|
s2 = "blaahhh"
|
|
|
|
Me.R.AssertEqualsString(s1, s2)
|
|
|
|
End
|
|
|
|
Public Sub TestAssertEqualsVariant()
|
|
|
|
Me.R.AssertEqualsVariant(1.2, 1.2)
|
|
Me.R.AssertEqualsVariant("blaahhh", "blaahhh")
|
|
Me.R.AssertEqualsVariant(12, 12)
|
|
|
|
End
|
|
|
|
Public Sub TestAssertError()
|
|
|
|
Dim r As Float
|
|
|
|
r = 2 / 0
|
|
Catch
|
|
|
|
Me.R.AssertError(26, "Division by zero")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertExists()
|
|
|
|
Me.R.AssertExists(Me, "I'm here")
|
|
|
|
End
|
|
|
|
Public Sub TestAssertFalse()
|
|
|
|
Me.R.AssertFalse(False)
|
|
|
|
End
|
|
|
|
Public Sub TestAssertNotEmpty()
|
|
|
|
Me.R.AssertNotEmpty(".")
|
|
Me.R.AssertNotEmpty("" & Null & 1)
|
|
Me.R.AssertNotEmpty(1)
|
|
Me.R.AssertNotEmpty(0)
|
|
Me.R.AssertNotNull(Me)
|
|
|
|
End
|
|
|
|
Public Sub TestAssertNotNull()
|
|
|
|
Me.R.AssertNotNull("" & Null & 1)
|
|
Me.R.AssertNotNull(Me)
|
|
|
|
End
|