secretive/Sources/Packages/Tests/BriefTests/SemVerTests.swift

53 lines
1.2 KiB
Swift
Raw Normal View History

2025-01-05 08:22:11 +00:00
import Testing
import Foundation
2020-09-22 07:17:22 +00:00
@testable import Brief
2025-01-05 08:22:11 +00:00
@Suite struct SemVerTests {
2020-09-22 07:17:22 +00:00
2025-01-05 08:22:11 +00:00
@Test func equal() {
2020-09-22 07:17:22 +00:00
let current = SemVer("1.0.2")
let old = SemVer("1.0.2")
2025-01-05 08:22:11 +00:00
#expect(!(current > old))
2020-09-22 07:17:22 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func patchGreaterButMinorLess() {
2020-09-22 07:17:22 +00:00
let current = SemVer("1.1.0")
let old = SemVer("1.0.2")
2025-01-05 08:22:11 +00:00
#expect(current > old)
2020-09-22 07:17:22 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func majorSameMinorGreater() {
2020-09-22 07:17:22 +00:00
let current = SemVer("1.0.2")
let new = SemVer("1.0.3")
2025-01-05 08:22:11 +00:00
#expect(current < new)
2020-09-22 07:17:22 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func majorGreaterMinorLesser() {
2020-11-12 01:13:21 +00:00
let current = SemVer("1.0.2")
let new = SemVer("2.0.0")
2025-01-05 08:22:11 +00:00
#expect(current < new)
2020-11-12 01:13:21 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func regularParsing() {
2021-01-18 08:49:26 +00:00
let current = SemVer("1.0.2")
2025-01-05 08:22:11 +00:00
#expect(current.versionNumbers == [1, 0, 2])
2021-01-18 08:49:26 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func noPatch() {
2021-01-18 08:49:26 +00:00
let current = SemVer("1.1")
2025-01-05 08:22:11 +00:00
#expect(current.versionNumbers == [1, 1, 0])
2021-01-18 08:49:26 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func garbage() {
2021-01-18 08:49:26 +00:00
let current = SemVer("Test")
2025-01-05 08:22:11 +00:00
#expect(current.versionNumbers == [0, 0, 0])
2021-01-18 08:49:26 +00:00
}
2025-01-05 08:22:11 +00:00
@Test func beta() {
2020-09-22 07:17:22 +00:00
let current = SemVer("1.0.2")
let new = SemVer("1.1.0_beta1")
2025-01-05 08:22:11 +00:00
#expect(current < new)
2020-09-22 07:17:22 +00:00
}
}