gambas-source-code/main/lib/test/gb.test/.src/TestMyself/TAllAsserts.test
Christof Thalhofer c0b7e7db82 gb.test Skip and Todo from Assert to Test
[GB.TEST]
* NEW: Skip and Todo from Assert to Test
2020-05-28 09:30:15 +02:00

132 lines
2.1 KiB
Text

' Gambas test file
''' Tests all Asserts
Public Sub Assert()
Test.Plan(1)
Assert.Ok(True, "Testing True")
End
Public Sub AssertEmpty()
Test.Plan(2)
Assert.Null("", "Empty with \"\"")
Assert.Null(Null, "Empty with Null")
End
Public Sub AssertEqualsFloat()
Dim f As Float
Test.Plan(1)
f = 0.55555555555555
Assert.Approximate(f, 0.55555555555555, 0, "Check with equal floats")
End
Public Sub AssertEqualsLong()
Dim l As Long
l = 555555555555555555
Test.Plan(1)
Assert.Equals(555555555555555555, l, "Check long")
End
Public Sub AssertEqualsDate()
Dim d As Date
Dim sdate As String
Dim d2 As Date
d = Now()
sdate = CString(d)
d2 = CDate(sdate)
Test.Plan(1)
Assert.Equals(d, d2, "Check with equal dates")
End
Public Sub AssertEqualsObject()
Dim s As New TestCase("1", Me)
Dim s2 As Object
s2 = s
Test.Plan(1)
Assert.Equals(s2, s, "Equal Objects")
End
Public Sub AssertEqualsString()
Dim s1, s2 As String
s1 = "blaahhh"
s2 = "blaahhh"
Test.Plan(1)
Assert.StringEquals(s1, s2, "Equal Strings")
End
Public Sub AssertNotNull()
Test.Plan(2)
Assert.NotNull("" & Null & 1, "String is not Null")
Assert.NotNull(Me, "Object is not Null")
End
Public Sub AssertError()
Dim r As Float
Test.Plan(1)
Try r = 2 / 0
Assert.Error("Test error")
End
Public Sub AssertErrorCode()
Dim r As Float
Test.Plan(1)
Try r = 2 / 0
Assert.ErrorCode(26, "Test error with code")
End
Public Sub TodoErrorCode()
Dim r As Float
Test.Plan(2)
Try r = 2 / 1
Test.Todo("See automatic diagnostics 1/2")
Assert.ErrorCode(26, "Division by zero?")
Try r = 2 / 0
Test.Todo("See automatic diagnostics 2/2")
Assert.ErrorCode(25, "Division by zero?")
End
Public Sub Note()
Test.Plan(0)
Test.Note("The next note is Null and that's alright:")
Test.Note(Null)
Test.SkipAll("This doesn't actually assert anything")
End
Public Sub Like()
Test.Plan(2)
Assert.Like("Gambas", "G*", "Gambas like G*")
Assert.Like("Gambas", "?[Aa]*", "Gambas Like \"?[Aa]*\"")
End