2019-11-15 22:33:54 +01:00
|
|
|
' Gambas class file
|
|
|
|
|
|
|
|
Inherits UnitTest
|
|
|
|
|
|
|
|
' Signal, that this is a selftest
|
|
|
|
Public Const ThisIsAnUnitTestSelfTest As Boolean = True
|
|
|
|
|
2020-01-24 10:10:39 +01:00
|
|
|
Public Sub _new()
|
|
|
|
|
|
|
|
Me.Plan = 12
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
|
2019-11-15 22:33:54 +01:00
|
|
|
Public Sub TestAssert()
|
|
|
|
|
|
|
|
Assert.True(True, "Testing True")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEmpty()
|
|
|
|
|
|
|
|
Assert.Null("", "Empty with \"\"")
|
|
|
|
Assert.Null(Null, "Empty with Null")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEqualsFloat()
|
|
|
|
|
|
|
|
Dim f As Float
|
|
|
|
|
|
|
|
f = 0.55555555555555
|
|
|
|
Assert.EqualsFloat(f, 0.55555555555555, 0, "Check with equal floats")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEqualsLong()
|
|
|
|
|
|
|
|
Dim l As Long
|
|
|
|
|
|
|
|
l = 555555555555555555
|
|
|
|
|
|
|
|
Assert.EqualsLong(555555555555555555, l, "Check with two long")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEqualsDate()
|
|
|
|
|
|
|
|
Dim d As Date
|
2019-12-30 22:10:37 +01:00
|
|
|
Dim sdate As String
|
2019-11-15 22:33:54 +01:00
|
|
|
Dim d2 As Date
|
|
|
|
|
|
|
|
d = Now()
|
2019-12-30 22:10:37 +01:00
|
|
|
sdate = CString(d)
|
|
|
|
d2 = CDate(sdate)
|
2019-11-15 22:33:54 +01:00
|
|
|
|
|
|
|
Assert.EqualsDate(d, d2, "Check with equal dates")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEqualsObject()
|
|
|
|
|
|
|
|
Dim s As New TestCase("1", Me)
|
|
|
|
Dim s2 As Object
|
|
|
|
|
|
|
|
s2 = s
|
|
|
|
|
|
|
|
Assert.EqualsObject(s2, s, "Equal Objects")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertEqualsString()
|
|
|
|
|
|
|
|
Dim s1, s2 As String
|
|
|
|
|
|
|
|
s1 = "blaahhh"
|
|
|
|
s2 = "blaahhh"
|
|
|
|
|
|
|
|
Assert.EqualsString(s1, s2, "Equal Strings")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertNotNull()
|
|
|
|
|
|
|
|
Assert.NotNull("" & Null & 1, "String is not Null")
|
|
|
|
Assert.NotNull(Me, "Object is not Null")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestAssertError()
|
|
|
|
|
|
|
|
Dim r As Float
|
|
|
|
Try r = 2 / 0
|
2019-12-30 22:10:37 +01:00
|
|
|
Assert.Error("Test error")
|
2019-11-15 22:33:54 +01:00
|
|
|
|
|
|
|
End
|
|
|
|
|
2019-12-30 22:10:37 +01:00
|
|
|
Public Sub TestAssertErrorWithCode()
|
|
|
|
|
|
|
|
Dim r As Float
|
|
|
|
Try r = 2 / 0
|
|
|
|
Assert.ErrorWithCode(26, "Test error with code")
|
|
|
|
|
2020-01-24 10:10:39 +01:00
|
|
|
End
|