Mercurial > public > simoleon
comparison SimoleonTests/SimoleonTests.swift @ 82:3133bf6f6deb
Implemented Unit Testing
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 01 Aug 2021 10:30:10 +0100 |
parents | d25b02d439d4 |
children | 879e20d2a837 |
comparison
equal
deleted
inserted
replaced
81:7bea61efd0b9 | 82:3133bf6f6deb |
---|---|
20 | 20 |
21 func testExample() throws { | 21 func testExample() throws { |
22 // This is an example of a functional test case. | 22 // This is an example of a functional test case. |
23 // Use XCTAssert and related functions to verify your tests produce the correct results. | 23 // Use XCTAssert and related functions to verify your tests produce the correct results. |
24 } | 24 } |
25 | |
26 func testMakeConversion() { | |
27 // Given | |
28 let testAmounts = ["iawuh", Int(100), Float(3450.30), Double(12530.43435)] as [Any] | |
29 | |
30 for var amountToConvert in testAmounts { | |
31 // When | |
32 if let amountToConvert = amountToConvert as? Double { | |
33 // Then | |
34 XCTAssertEqual(amountToConvert, amountToConvert, "Amount to convert is not returning correctly") | |
35 } else { | |
36 // Then | |
37 amountToConvert = Int(0) | |
38 XCTAssertEqual(amountToConvert as! Int, 0, "Amount to convert must be 0") | |
39 } | |
40 } | |
41 } | |
42 | |
43 func testFormatCurrency() { | |
44 // Given | |
45 let availableIdentifiers = Locale.availableIdentifiers | |
46 let amount: NSDecimalNumber = 1000 | |
47 | |
48 for identifier in availableIdentifiers { | |
49 let locale = Locale(identifier: identifier) | |
50 | |
51 let formatter = NumberFormatter() | |
52 formatter.locale = locale | |
53 formatter.numberStyle = .currency | |
54 | |
55 XCTAssertTrue((formatter.string(from: amount as NSNumber) != nil)) | |
56 } | |
57 | |
58 } | |
25 | 59 |
26 func testPerformanceExample() throws { | 60 func testPerformanceExample() throws { |
27 // This is an example of a performance test case. | 61 // This is an example of a performance test case. |
28 self.measure { | 62 self.measure { |
29 // Put the code you want to measure the time of here. | 63 // Put the code you want to measure the time of here. |