Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully implement splittext and add test #1560

Merged
merged 10 commits into from
Jan 7, 2024
Prev Previous commit
I am dum
  • Loading branch information
amylizzle committed Jan 7, 2024
commit b16f156bd8be58d0b4d74f9420060781c7efe111
16 changes: 8 additions & 8 deletions Content.Tests/DMProject/Tests/Text/Splittext.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
var/test_text = "The average of 1, 2, 3, 4, 5 is: 3"
var/list/test1 = splittext(test_text, " ")
var/list/test1_expected = list("The","average","of","1,","2,","3,","4,","5","is:","3")
test1 ~= test1_expected
ASSERT(test1 ~= test1_expected)

var/list/test2 = splittext(test_text, " ", 5)
var/test2_expected = list("average","of","1,","2,","3,","4,","5","is:","3")
test2 ~= test2_expected
ASSERT(test2 ~= test2_expected)

var/list/test3 = splittext(test_text, " ", 5, 10)
var/test3_expected = list("avera")
test3 ~= test3_expected
ASSERT(test3 ~= test3_expected)

var/list/test4 = splittext(test_text, " ", 10, 20)
var/test4_expected = list("ge","of","1,","2")
test4 ~= test4_expected
ASSERT(test4 ~= test4_expected)

var/list/test5 = splittext(test_text, " ", 10, 20, 1)
var/test5_expected = list("ge"," ","of"," ","1,"," ","2")
test5 ~= test5_expected
ASSERT(test5 ~= test5_expected)

//it's regex time
var/test6 = splittext(test_text, regex(@"\d"))
var/test6_expected = list("The average of ",", ",", ",", ",", "," is: ","")
test6 ~= test6_expected
ASSERT(test6 ~= test6_expected)

var/test7 = splittext(test_text, regex(@"\d"), 5, 30)
var/test7_expected = list("average of ",", ",", ",", ",", "," ")
test7 ~= test7_expected
ASSERT(test7 ~= test7_expected)

var/test8 = splittext(test_text, regex(@"\d"), 5, 30, 1)
var/test8_expected = list("average of ","1",", ","2",", ","3",", ","4",", ","5"," ")
test8 ~= test8_expected
ASSERT(test8 ~= test8_expected)
Loading