summaryrefslogtreecommitdiff
path: root/lib/escfmt/test/escre.myr
blob: 0ded0337ed5ca65318fbfd5b6258c430999389ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std
use escfmt
use testr

const main = {
	testr.run([\
		[.name="unchanged", .fn={ctx
			var s = std.fmt("{}", escfmt.url("word"))
			testr.check(ctx, std.eq("word", s), std.fmt("mismatched escape {}", s))
			std.slfree(s)
		}],
		[.name="randomcrud", .fn={ctx
			var s = std.fmt("{}", escfmt.re("^:/?#[]@!$&'()*+,;=%"))
			testr.check(ctx, \
				std.eq("\\^:/\\?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=%", s), \
				std.fmt("mismatched escape {}", s))
			std.slfree(s)
		}],
	][:])
}