Skip to content

Commit

Permalink
More tests for strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
smimram committed Aug 23, 2019
1 parent 04e98bd commit ac80f3c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/tests/string.liq
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env liquidsoap

%include "test.liq"

success = ref(true)
Expand All @@ -19,7 +21,14 @@ test(string.match(pattern=".*ab.*","cccabc"), true)
test(string.match(pattern=".*ab.*","cccbac"), false)
test(string.trim(" abc "), "abc")
test(string.sub("abcd",start=1,length=2), "bc")
test(string.sub("ab",start=0,length=10), "")
test(string.sub("ab",start=10,length=5), "")
test(string.contains(prefix="ab","abcd"), true)
test(string.contains(prefix="ba","abcd"), false)
test(string.contains(prefix="abcd","ab"), false)
test(string.contains(suffix="cd","abcd"), true)
test(string.contains(suffix="dc","abcd"), false)
test(string.contains(substring="bc","abcd"), true)
test(string.contains(substring="bc","acbd"), false)

if !success then test.pass() else test.fail() end
if !success then test.pass() else test.fail() end

0 comments on commit ac80f3c

Please sign in to comment.