forked from Pluto-tv/JSONHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatTests.swift
More file actions
52 lines (42 loc) · 1.08 KB
/
FloatTests.swift
File metadata and controls
52 lines (42 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Copyright © 2016 Baris Sencan. All rights reserved.
//
import Foundation
import XCTest
import JSONHelper
class FloatTests: XCTestCase {
let testInt = 1
let testFloat = Float(1.2)
let testDouble = Double(1.2)
let testNSNumber = NSNumber(value: 1.2 as Double)
let testNSDecimalNumber = NSDecimalNumber(value: 1.2 as Double)
let testString = "1.2"
var value = Float(0)
override func setUp() {
value = Float(0)
}
func testIntConversion() {
value <-- (testInt as Any)
XCTAssert(Int(value) == testInt)
}
func testFloatConversion() {
value <-- (testFloat as Any)
XCTAssertEqual(value, testFloat)
}
func testDoubleConversion() {
value <-- (testDouble as Any)
XCTAssertEqual(value, testFloat)
}
func testNSNumberConversion() {
value <-- (testNSNumber as Any)
XCTAssertEqual(value, testFloat)
}
func testNSDecimalNumberConversion() {
value <-- (testNSDecimalNumber as Any)
XCTAssertEqual(value, testFloat)
}
func testStringConversion() {
value <-- (testString as Any)
XCTAssertEqual(value, testFloat)
}
}