

Task

Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome.

If your language does not have a testing specific library well known to the language's community then state this or omit the language.



 
Sub StrReverse(Byref text As String)
    Dim As Integer x, lt = Len(text)
    For x = 0 To lt Shr 1 - 1
        Swap text[x], text[lt - x - 1]
    Next x
 
End Sub
 
Sub Replace(Byref T As String, Byref I As String, Byref S As String, Byval A As Integer = 1)
    Var p = Instr(A, T, I), li = Len(I), ls = Len(S) : If li = ls Then li = 0
    Do While p
        If li Then T = Left(T, p - 1) & S & Mid(T, p + li) Else Mid(T, p) = S
        p = Instr(p + ls, T, I)
    Loop
End Sub
 
Function IsPalindrome(Byval txt As String) As Boolean
    Dim As String tempTxt = Lcase(txt), copyTxt = Lcase(txt)
    Replace(tempTxt, " ", "")
    Replace(copyTxt, " ", "")
 
    StrReverse(tempTxt)
    If tempTxt = copyTxt Then 
        Color 10
        Return true 
    Else 
        Color 12
        Return false
    End If
End Function
 
'--- Programa Principal ---
Dim As String a(10) => {"abba", "mom", "dennis sinned", "Un roc lamina l animal cornu", _
"palindrome", "ba _ ab", "racecars", "racecar", "wombat", "in girum imus nocte et consumimur igni"}
 
Print !"¨Pal¡ndromos?\n"
For i As Byte = 0 To Ubound(a)-1
    Print a(i) & " -> ";
    Print IsPalindrome((a(i)))
    Color 7
Next i
Sleep
 