added more regex replace tests

This commit is contained in:
BroodjeAap 2022-12-28 10:37:57 +00:00
parent 95a01e7007
commit 6ed94864ff
2 changed files with 20 additions and 4 deletions

View file

@ -145,6 +145,7 @@ func TestFilterReplace(t *testing.T) {
Var2 string
Want string
}{
// remove tests
{"0123456789", "0", "", "123456789"},
{"0123456789", "9", "", "012345678"},
{"0123456789", "3456", "", "012789"},
@ -152,9 +153,25 @@ func TestFilterReplace(t *testing.T) {
{"世界日本語", "世", "", "界日本語"},
{"世界日本語", "語", "", "世界日本"},
{"世界日_世界日_世界日", "界", "", "世日_世日_世日"},
// TODO add replace tests
// TODO add regex tests
// TODO add regex replace tests
// replace tests
{"0123456789", "0", "a", "a123456789"},
{"0123456789", "9", "b", "012345678b"},
{"0123456789", "3456", "abcd", "012abcd789"},
{"0123456789_0123456789", "3456", "abcd", "012abcd789_012abcd789"},
{"世界日本語", "世", "本語", "本語界日本語"},
{"世界日本語", "語", "日", "世界日本日"},
{"世界日_世界日_世界日", "界", "語", "世語日_世語日_世語日"},
// regex tests
{"0123456789", "0[0-9]{2}", "", "3456789"},
{"0123456789", "[0-9]{2}9", "", "0123456"},
{"0123456789", "[0-9]+", "", ""},
{"Hello World!", "[eo]", "", "Hll Wrld!"},
{"世界日本語", "[界本]", "", "世日語"},
// regex replace tests
{"<span>123.65</span>", "<span>([0-9.]+)</span>", "$1", "123.65"},
}
for _, test := range tests {

View file

@ -5,6 +5,5 @@
- trusted proxies in conf?
- log things to db for cron runs
- comments
- add test for regex replace with group
- run/fix staticcheck
- add browserless support ?