Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update support iOS version to iOS 8.0; remove characters on Swift4 #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions PySwiftyRegex.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = PySwiftyRegex/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = me.cezheng.PySwiftyRegex;
Expand Down Expand Up @@ -333,7 +335,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = PySwiftyRegex/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = me.cezheng.PySwiftyRegex;
PRODUCT_NAME = "$(PROJECT_NAME)";
Expand All @@ -357,7 +361,7 @@
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACH_O_TYPE = mh_dylib;
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
Expand All @@ -376,7 +380,7 @@
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACH_O_TYPE = mh_dylib;
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
3 changes: 1 addition & 2 deletions PySwiftyRegex/PySwiftyRegex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ public class re {
guard let result = result, result.range.length > 0 else {
return
}

end = string.characters.index(string.startIndex, offsetBy: result.range.location)
end = string.index(string.startIndex, offsetBy: result.range.location)
results.append(String(string[start..<end]))
if regex.numberOfCaptureGroups > 0 {
results += MatchObject(string: string, match: result).groups()
Expand Down
34 changes: 17 additions & 17 deletions PySwiftyRegexTests/ReRegexObjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 4))
XCTAssertEqual(match.span(2)!, string.characters.index(string.startIndex, offsetBy: 27)..<string.characters.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span()!, string.startIndex..<string.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.index(string.startIndex, offsetBy: 4))
XCTAssertEqual(match.span(2)!, string.index(string.startIndex, offsetBy: 27)..<string.index(string.startIndex, offsetBy: 31))
}

func testMatchWithRangeSuccess() {
Expand All @@ -48,9 +48,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that on")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.characters.index(string.startIndex, offsetBy: 4)..<string.characters.index(string.startIndex, offsetBy: 38))
XCTAssertEqual(match.span(1)!, string.characters.index(string.startIndex, offsetBy: 4)..<string.characters.index(string.startIndex, offsetBy: 8))
XCTAssertEqual(match.span(2)!, string.characters.index(string.startIndex, offsetBy: 31)..<string.characters.index(string.startIndex, offsetBy: 35))
XCTAssertEqual(match.span()!, string.index(string.startIndex, offsetBy: 4)..<string.index(string.startIndex, offsetBy: 38))
XCTAssertEqual(match.span(1)!, string.index(string.startIndex, offsetBy: 4)..<string.index(string.startIndex, offsetBy: 8))
XCTAssertEqual(match.span(2)!, string.index(string.startIndex, offsetBy: 31)..<string.index(string.startIndex, offsetBy: 35))
}

func testMatchFailure() {
Expand All @@ -70,9 +70,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 4))
XCTAssertEqual(match.span(2)!, string.characters.index(string.startIndex, offsetBy: 27)..<string.characters.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span()!, string.startIndex..<string.index(string.startIndex, offsetBy: 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.index(string.startIndex, offsetBy: 4))
XCTAssertEqual(match.span(2)!, string.index(string.startIndex, offsetBy: 27)..<string.index(string.startIndex, offsetBy: 31))
}

func testSearchWithRangeSuccess() {
Expand All @@ -85,9 +85,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that on")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.characters.index(string.startIndex, offsetBy: 4)..<string.characters.index(string.startIndex, offsetBy: 38))
XCTAssertEqual(match.span(1)!, string.characters.index(string.startIndex, offsetBy: 4)..<string.characters.index(string.startIndex, offsetBy: 8))
XCTAssertEqual(match.span(2)!, string.characters.index(string.startIndex, offsetBy: 31)..<string.characters.index(string.startIndex, offsetBy: 35))
XCTAssertEqual(match.span()!, string.index(string.startIndex, offsetBy: 4)..<string.index(string.startIndex, offsetBy: 38))
XCTAssertEqual(match.span(1)!, string.index(string.startIndex, offsetBy: 4)..<string.index(string.startIndex, offsetBy: 8))
XCTAssertEqual(match.span(2)!, string.index(string.startIndex, offsetBy: 31)..<string.index(string.startIndex, offsetBy: 35))
}

func testSearchNestGroupsSuccess() {
Expand All @@ -102,11 +102,11 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group(2)!, "this ")
XCTAssertEqual(match.group(3)!, " that that that ")
XCTAssertEqual(match.group(4)!, "that ")
XCTAssertEqual(match.span()!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 52))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.characters.index(string.startIndex, offsetBy: 15))
XCTAssertEqual(match.span(2)!, string.characters.index(string.startIndex, offsetBy: 10)..<string.characters.index(string.startIndex, offsetBy: 15))
XCTAssertEqual(match.span(3)!, string.characters.index(string.startIndex, offsetBy: 36)..<string.characters.index(string.startIndex, offsetBy: 52))
XCTAssertEqual(match.span(4)!, string.characters.index(string.startIndex, offsetBy: 47)..<string.characters.index(string.startIndex, offsetBy: 52))
XCTAssertEqual(match.span()!, string.startIndex..<string.index(string.startIndex, offsetBy: 52))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.index(string.startIndex, offsetBy: 15))
XCTAssertEqual(match.span(2)!, string.index(string.startIndex, offsetBy: 10)..<string.index(string.startIndex, offsetBy: 15))
XCTAssertEqual(match.span(3)!, string.index(string.startIndex, offsetBy: 36)..<string.index(string.startIndex, offsetBy: 52))
XCTAssertEqual(match.span(4)!, string.index(string.startIndex, offsetBy: 47)..<string.index(string.startIndex, offsetBy: 52))
}

func testFindallSuccess() {
Expand Down