-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNumbersTests.swift
36 lines (31 loc) · 1.65 KB
/
NumbersTests.swift
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
import XCTest
import WinRTComponent
class NumberTests: WinRTTestCase {
func testBool() throws {
XCTAssertEqual(try WinRTComponent_Numbers.not(false), true)
}
func testIntegers() throws {
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt8(1), 2)
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt16(0xFF), 0x100)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt16(0xFF), 0x100)
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt32(0xFFFF), 0x1_0000)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt32(0xFFFF), 0x1_0000)
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt64(0xFFFF_FFFF), 0x1_0000_0000)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt64(0xFFFF_FFFF), 0x1_0000_0000)
}
func testSignedIntegerOverflow() throws {
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt16(Int16.max), Int16.min)
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt32(Int32.max), Int32.min)
XCTAssertEqual(try WinRTComponent_Numbers.incrementInt64(Int64.max), Int64.min)
}
func testUnsignedSignedIntegerOverflow() throws {
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt8(UInt8.max), 0)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt16(UInt16.max), 0)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt32(UInt32.max), 0)
XCTAssertEqual(try WinRTComponent_Numbers.incrementUInt64(UInt64.max), 0)
}
func testSingle() throws {
XCTAssertEqual(try WinRTComponent_Numbers.negateSingle(42), -42)
XCTAssertEqual(try WinRTComponent_Numbers.negateDouble(42), -42)
}
}