mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			99 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			99 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
| // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
 | |
| 
 | |
| import Foundation
 | |
| 
 | |
| import Quick
 | |
| import Nimble
 | |
| 
 | |
| @testable import SessionUtilitiesKit
 | |
| 
 | |
| class VersionSpec: QuickSpec {
 | |
|     // MARK: - Spec
 | |
| 
 | |
|     override func spec() {
 | |
|         describe("a Version") {
 | |
|             it("can be created from a string") {
 | |
|                 let version: Version = Version.from("1.20.3")
 | |
|                 
 | |
|                 expect(version.major).to(equal(1))
 | |
|                 expect(version.minor).to(equal(20))
 | |
|                 expect(version.patch).to(equal(3))
 | |
|             }
 | |
|             
 | |
|             it("correctly exposes a string value") {
 | |
|                 let version: Version = Version(major: 1, minor: 20, patch: 3)
 | |
|                 
 | |
|                 expect(version.stringValue).to(equal("1.20.3"))
 | |
|             }
 | |
|             
 | |
|             context("when checking equality") {
 | |
|                 it("returns true if the values match") {
 | |
|                     let version1: Version = Version.from("1.0.0")
 | |
|                     let version2: Version = Version.from("1.0.0")
 | |
|                     
 | |
|                     expect(version1 == version2)
 | |
|                         .to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns false if the values do not match") {
 | |
|                     let version1: Version = Version.from("1.0.0")
 | |
|                     let version2: Version = Version.from("1.0.1")
 | |
|                     
 | |
|                     expect(version1 == version2)
 | |
|                         .to(beFalse())
 | |
|                 }
 | |
|             }
 | |
|             
 | |
|             context("when comparing versions") {
 | |
|                 it("returns correctly for a simple major difference") {
 | |
|                     let version1: Version = Version.from("1.0.0")
 | |
|                     let version2: Version = Version.from("2.0.0")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns correctly for a complex major difference") {
 | |
|                     let version1: Version = Version.from("2.90.90")
 | |
|                     let version2: Version = Version.from("10.0.0")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns correctly for a simple minor difference") {
 | |
|                     let version1: Version = Version.from("1.0.0")
 | |
|                     let version2: Version = Version.from("1.1.0")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns correctly for a complex minor difference") {
 | |
|                     let version1: Version = Version.from("90.2.90")
 | |
|                     let version2: Version = Version.from("90.10.0")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns correctly for a simple patch difference") {
 | |
|                     let version1: Version = Version.from("1.0.0")
 | |
|                     let version2: Version = Version.from("1.0.1")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|                 
 | |
|                 it("returns correctly for a complex patch difference") {
 | |
|                     let version1: Version = Version.from("90.90.2")
 | |
|                     let version2: Version = Version.from("90.90.10")
 | |
|                     
 | |
|                     expect(version1 < version2).to(beTrue())
 | |
|                     expect(version2 > version1).to(beTrue())
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |