From 87b2ff9a2e2e578f57e904cafe51ae04cf3b6383 Mon Sep 17 00:00:00 2001 From: Romain Bossart Date: Fri, 30 Sep 2016 00:09:34 +0200 Subject: [PATCH] add replace tests --- Modules/POSIX/Tests/POSIXTests/RegexTests.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Modules/POSIX/Tests/POSIXTests/RegexTests.swift b/Modules/POSIX/Tests/POSIXTests/RegexTests.swift index b56db037..8117072c 100644 --- a/Modules/POSIX/Tests/POSIXTests/RegexTests.swift +++ b/Modules/POSIX/Tests/POSIXTests/RegexTests.swift @@ -85,6 +85,18 @@ public class RegexTests: XCTestCase { let string = regex.replace(in: "hello world", with: "bye") XCTAssert(string == "hello world") } + + func testReplaceUTF8() throws { + let r0 = try Regex(pattern: "coffee") + let actual0 = r0.replace(in: "Paulo loves coffee", with: "☕️") + XCTAssertEqual(actual0, "Paulo loves ☕️") + } + + func testMultipleReplacesUTF8() throws { + let r1 = try Regex(pattern: "[[:digit:]]{4}") + let actual1 = r1.replace(in: "1234-2345-3456-4567", with: "💳") + XCTAssertEqual(actual1, "💳-💳-💳-💳") + } /// MARK: - matching test