comparison SimoleonTests/SimoleonTests.swift @ 120:cd801949925b

Remove 1000 from default currency conversion
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Sun, 15 Aug 2021 11:10:39 +0100
parents 879e20d2a837
children bdedd0cc6cd1
comparison
equal deleted inserted replaced
119:f9d8b3c6597f 120:cd801949925b
15 } 15 }
16 16
17 override func tearDownWithError() throws { 17 override func tearDownWithError() throws {
18 // Put teardown code here. This method is called after the invocation of each test method in the class. 18 // Put teardown code here. This method is called after the invocation of each test method in the class.
19 } 19 }
20
21 func testMakeConversion() {
22 // Given
23 let testAmounts = ["iawuh", Int(100), Float(3450.30), Double(12530.43435)] as [Any]
24
25 for var amountToConvert in testAmounts {
26 // When
27 if let amountToConvert = amountToConvert as? Double {
28 // Then
29 XCTAssertEqual(amountToConvert, amountToConvert, "Amount to convert is not returning correctly")
30 } else {
31 // Then
32 amountToConvert = Int(0)
33 XCTAssertEqual(amountToConvert as! Int, 0, "Amount to convert must be 0")
34 }
35 }
36 }
37
38 func testFormatCurrency() {
39 // Given
40 let availableIdentifiers = Locale.availableIdentifiers
41 let amount: NSDecimalNumber = 1000
42
43 for identifier in availableIdentifiers {
44 let locale = Locale(identifier: identifier)
45
46 let formatter = NumberFormatter()
47 formatter.locale = locale
48 formatter.numberStyle = .currency
49
50 XCTAssertTrue((formatter.string(from: amount as NSNumber) != nil))
51 }
52
53 }
54 20
55 func testPerformanceExample() throws { 21 func testPerformanceExample() throws {
56 // This is an example of a performance test case. 22 // This is an example of a performance test case.
57 self.measure { 23 self.measure {
58 // Put the code you want to measure the time of here. 24 // Put the code you want to measure the time of here.