Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Test-a-function/Odin/test-a-function.odin
Normal file
26
Task/Test-a-function/Odin/test-a-function.odin
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// To run execute: odin test Test_a_function.odin -file
|
||||
package main
|
||||
|
||||
import "core:testing"
|
||||
import "core:strings"
|
||||
|
||||
is_palindrome :: proc(s: string) -> bool {
|
||||
return s == strings.reverse(s)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_is_palindrome :: proc(t: ^testing.T) {
|
||||
palindromes := []string{"", "a", "aa", "aba", "racecar"}
|
||||
for i in palindromes {
|
||||
if !is_palindrome(i) {
|
||||
testing.errorf(t, "is_palindrome returned false on palindrome %s", i)
|
||||
}
|
||||
}
|
||||
|
||||
non_palindromes := []string{"ab", "abaa", "aaba", "abcdba"}
|
||||
for i in non_palindromes {
|
||||
if is_palindrome(i) {
|
||||
testing.errorf(t, "is_palindrome returned true on non-palindrome %s", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue