Test a function: Difference between revisions
Content added Content deleted
(add minimal Euphoria testing code) |
(Added Ada) |
||
Line 1: | Line 1: | ||
{{task|Testing}} |
{{task|Testing}} |
||
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. |
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. |
||
=={{header|Ada}}== |
|||
For normal use there is pragma Assert, functioning the same as many other languages.<br> |
|||
For larger testing frameworks, there are packages like [http://libre.adacore.com/libre/tools/aunit/ Aunit] |
|||
<lang Ada> |
|||
procedure TestFunction is |
|||
function Palindrome (Text : String) return Boolean is |
|||
begin |
|||
for Offset in 0 .. Text'Length / 2 - 1 loop |
|||
if Text (Text'First + Offset) /= Text (Text'Last - Offset) then |
|||
return False; |
|||
end if; |
|||
end loop; |
|||
return True; |
|||
end Palindrome; |
|||
str1 : String := "racecar"; |
|||
str2 : String := "wombat"; |
|||
begin |
|||
pragma Assert (Palindrome (str1) = True, "Assertion on str1 failed"); |
|||
pragma Assert (Palindrome (str2) = False, "Assertion on str2 failed"); |
|||
null; -- Needed since there were no statements |
|||
end TestFunction; |
|||
</lang> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
there is no "well known" testing library, but here is a simple testing framework: <br> |
there is no "well known" testing library, but here is a simple testing framework: <br> |