2020-02-23 12:38:53 +01:00
|
|
|
' Gambas test file
|
2019-11-15 22:33:54 +01:00
|
|
|
|
|
|
|
Public Const ThisIsAnUnitTestSelfTest As Boolean = True
|
2020-02-23 12:38:53 +01:00
|
|
|
Public Plan As Integer = 11
|
2019-11-15 22:33:54 +01:00
|
|
|
|
2020-02-23 12:38:53 +01:00
|
|
|
Public Sub Setup()
|
2020-01-22 09:13:41 +01:00
|
|
|
|
2020-02-23 12:38:53 +01:00
|
|
|
Assert.Note("------------------ Intentional Failures ------------------")
|
2020-01-22 09:13:41 +01:00
|
|
|
|
|
|
|
End
|
|
|
|
|
2020-02-23 12:38:53 +01:00
|
|
|
Public Sub Teardown()
|
2019-12-30 22:10:37 +01:00
|
|
|
|
|
|
|
Assert.Note("------------------ End Intentional Failures ------------------")
|
2020-01-22 09:13:41 +01:00
|
|
|
Assert.Note("11 Tests, 11 Failures, then everything is ok.")
|
2019-12-30 22:10:37 +01:00
|
|
|
|
2020-02-23 12:38:53 +01:00
|
|
|
End
|
2019-12-30 22:10:37 +01:00
|
|
|
|
2019-11-15 22:33:54 +01:00
|
|
|
Public Sub TestStringFailure()
|
|
|
|
|
2019-12-30 22:10:37 +01:00
|
|
|
Assert.EqualsString("Lisa", "Paul", "Intentional String failure. Ok if not ok.")
|
2019-11-15 22:33:54 +01:00
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestLongFailure()
|
|
|
|
|
|
|
|
Assert.EqualsLong(2, 3, "Intentional Long failure. Ok if not ok.")
|
|
|
|
|
|
|
|
End
|
2019-12-30 22:10:37 +01:00
|
|
|
|
|
|
|
Public Sub TestLongTypeMismatchFailure()
|
|
|
|
|
|
|
|
Dim s As String = "3.0"
|
|
|
|
|
|
|
|
Assert.EqualsLong(s, 3, "Intentional Long type mismatch failure. Ok if not ok.")
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestEqualsFailure()
|
|
|
|
|
|
|
|
Dim oOne, oTwo As Object
|
|
|
|
|
|
|
|
Assert.Note("Equals failures")
|
|
|
|
Assert.Equals(2, 3)
|
|
|
|
Assert.Equals("3", 2.0)
|
|
|
|
Assert.Equals("2", 2.1)
|
|
|
|
oOne = New ITest
|
|
|
|
oTwo = New ITest
|
|
|
|
Assert.Equals(oOne, oTwo)
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestDoACrash()
|
|
|
|
|
|
|
|
Dim a As Long
|
|
|
|
|
|
|
|
'Me.AddTrace("This will be a crash, then its ok")
|
|
|
|
|
|
|
|
'This is a crash
|
|
|
|
a = 3 / 0
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
Public Sub TestError()
|
|
|
|
|
|
|
|
Dim a As Long
|
|
|
|
|
|
|
|
Try a = 3 / 0
|
|
|
|
Assert.ErrorWithCode(5, "Wanted error 5. Ok if not ok.")
|
2020-02-23 12:38:53 +01:00
|
|
|
|
2019-12-30 22:10:37 +01:00
|
|
|
' No Error, AssertError has to report a failure
|
|
|
|
Assert.Error("No Error but error expected. Ok if not ok.")
|
|
|
|
|
|
|
|
End
|
2020-01-22 09:13:41 +01:00
|
|
|
|
|
|
|
Public Sub TestErrorTwo()
|
|
|
|
|
2020-02-23 12:38:53 +01:00
|
|
|
Error.Raise("I shot the sheriff.")
|
2020-01-22 09:13:41 +01:00
|
|
|
Assert.True(True)
|
|
|
|
|
|
|
|
End
|
|
|
|
|
2019-12-30 22:10:37 +01:00
|
|
|
'
|