summary refs log tree commit diff stats
path: root/tests/stdlib/nre/misc.nim
blob: dbb0ecdf9c3c1e32145d36fbcc2cfdbe778ce107 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import unittest, nre, strutils, optional_nonstrict

block: # Misc tests
  block: # unicode
    check("".find(re"(*UTF8)").match == "")
    check("перевірка".replace(re"(*U)\w", "") == "")

  block: # empty or non-empty match
    check("abc".findall(re"|.").join(":") == ":a::b::c:")
    check("abc".findall(re".|").join(":") == "a:b:c:")

    check("abc".replace(re"|.", "x") == "xxxxxxx")
    check("abc".replace(re".|", "x") == "xxxx")

    check("abc".split(re"|.").join(":") == ":::::")
    check("abc".split(re".|").join(":") == ":::")