Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ extension SemanticVersion: LosslessStringConvertible {
let semVerRegex = #/
^
v? # SPI extension: allow leading 'v'
(?<major>0|[1-9]\d*)
(?<major>\d+) # SPI extension: allow leading 0
\.
(?<minor>0|[1-9]\d*)
(?<minor>\d+) # SPI extension: allow leading 0
\.
(?<patch>0|[1-9]\d*)
(?<patch>\d+) # SPI extension: allow leading 0
(?:-
(?<prerelease>
(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)
Expand Down
11 changes: 8 additions & 3 deletions Tests/SemanticVersionTests/SemanticVersionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ final class SemanticVersionTests: XCTestCase {
XCTAssertNotNil("1.0.0".wholeMatch(of: semVerRegex))
XCTAssertNotNil("2.0.0".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.1.7".wholeMatch(of: semVerRegex))
XCTAssertNotNil("01.1.1".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.01.1".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.1.01".wholeMatch(of: semVerRegex))
XCTAssertNotNil("001.1.1".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.001.1".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.1.001".wholeMatch(of: semVerRegex))
XCTAssertNotNil("2.0.0+build.1848".wholeMatch(of: semVerRegex))
XCTAssertNotNil("2.0.1-alpha.1227".wholeMatch(of: semVerRegex))
XCTAssertNotNil("1.0.0-alpha+beta".wholeMatch(of: semVerRegex))
Expand Down Expand Up @@ -83,9 +89,6 @@ final class SemanticVersionTests: XCTestCase {
XCTAssertNil("1.0.0-alpha.....1".wholeMatch(of: semVerRegex))
XCTAssertNil("1.0.0-alpha......1".wholeMatch(of: semVerRegex))
XCTAssertNil("1.0.0-alpha.......1".wholeMatch(of: semVerRegex))
XCTAssertNil("01.1.1".wholeMatch(of: semVerRegex))
XCTAssertNil("1.01.1".wholeMatch(of: semVerRegex))
XCTAssertNil("1.1.01".wholeMatch(of: semVerRegex))
XCTAssertNil("1.2".wholeMatch(of: semVerRegex))
XCTAssertNil("1.2.3.DEV".wholeMatch(of: semVerRegex))
XCTAssertNil("1.2-SNAPSHOT".wholeMatch(of: semVerRegex))
Expand All @@ -110,6 +113,8 @@ final class SemanticVersionTests: XCTestCase {
XCTAssertEqual(SemanticVersion("1.2"), nil)
XCTAssertEqual(SemanticVersion("1.2.3rc"), nil)
XCTAssertEqual(SemanticVersion("swift-2.2-SNAPSHOT-2016-01-11-a"), nil)
XCTAssertEqual(SemanticVersion("01.02.03"), SemanticVersion(1, 2, 3))
XCTAssertEqual(SemanticVersion("001.002.003"), SemanticVersion(1, 2, 3))
}

func test_description() throws {
Expand Down
Loading