aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-10-25 23:01:23 +0200
committerLouis Pilfold <louis@lpil.uk>2022-10-27 15:13:03 +0100
commited9405a0eb12061b3ce680f80e6d89b5ff518f21 (patch)
tree107d7ea2116fef3358c8ecd88ee84e8d8a2e315e /test
parentc758631b79d594b884a8031182464e9251bd9ee4 (diff)
downloadgleam_stdlib-ed9405a0eb12061b3ce680f80e6d89b5ff518f21.tar.gz
gleam_stdlib-ed9405a0eb12061b3ce680f80e6d89b5ff518f21.zip
fix regex.scan to work correclty with utf8 strings
Diffstat (limited to 'test')
-rw-r--r--test/gleam/regex_test.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/gleam/regex_test.gleam b/test/gleam/regex_test.gleam
index cdd6e68..30d197f 100644
--- a/test/gleam/regex_test.gleam
+++ b/test/gleam/regex_test.gleam
@@ -64,4 +64,18 @@ pub fn scan_test() {
Match(content: "on a boat", submatches: [None, Some("boat")]),
Match(content: "in a lake", submatches: [None, Some("lake")]),
])
+
+ assert Ok(re) = regex.from_string("answer (\\d+)")
+ regex.scan(re, "Is the answer 42?")
+ |> should.equal([Match(content: "answer 42", submatches: [Some("42")])])
+
+ assert Ok(re) = regex.from_string("(\\d+)")
+ regex.scan(re, "hello 42")
+ |> should.equal([Match(content: "42", submatches: [Some("42")])])
+
+ regex.scan(re, "你好 42")
+ |> should.equal([Match(content: "42", submatches: [Some("42")])])
+
+ regex.scan(re, "你好 42 世界")
+ |> should.equal([Match(content: "42", submatches: [Some("42")])])
}