@@ -9,8 +9,16 @@ class ConveniencePropertiesTests: XCTestCase {
9
9
( " testIndexedSubscript " , testIndexedSubscript) ,
10
10
( " testKeyedSubscript " , testKeyedSubscript) ,
11
11
( " testIsNil " , testIsNil) ,
12
- ( " testIntegerValue " , testIntegerValue) ,
13
- ( " testUnsignedIntegerValue " , testUnsignedIntegerValue) ,
12
+ ( " testIntValue " , testIntValue) ,
13
+ ( " testInt8Value " , testInt8Value) ,
14
+ ( " testInt16Value " , testInt16Value) ,
15
+ ( " testIn32Value " , testInt32Value) ,
16
+ ( " testInt64Value " , testInt64Value) ,
17
+ ( " testUIntValue " , testUIntValue) ,
18
+ ( " testUInt8Value " , testUInt8Value) ,
19
+ ( " testUInt16Value " , testUInt16Value) ,
20
+ ( " testUInt32Value " , testUInt32Value) ,
21
+ ( " testUInt64Value " , testUInt64Value) ,
14
22
( " testArrayValue " , testArrayValue) ,
15
23
( " testBoolValue " , testBoolValue) ,
16
24
( " testFloatValue " , testFloatValue) ,
@@ -46,17 +54,98 @@ class ConveniencePropertiesTests: XCTestCase {
46
54
XCTAssertFalse ( MessagePackValue . bool ( true ) . isNil)
47
55
}
48
56
49
- func testIntegerValue ( ) {
50
- XCTAssert ( MessagePackValue . int ( - 1 ) . integerValue == - 1 )
51
- XCTAssert ( MessagePackValue . uint ( 1 ) . integerValue == 1 )
52
- XCTAssert ( MessagePackValue . nil. integerValue == nil )
57
+ func testIntValue ( ) {
58
+ XCTAssert ( MessagePackValue . int ( - 1 ) . intValue == - 1 )
59
+ XCTAssert ( MessagePackValue . uint ( 1 ) . intValue == 1 )
60
+ XCTAssertNil ( MessagePackValue . nil. intValue )
53
61
}
54
62
55
- func testUnsignedIntegerValue( ) {
56
- XCTAssert ( MessagePackValue . int ( - 1 ) . unsignedIntegerValue == nil )
57
- XCTAssert ( MessagePackValue . int ( 1 ) . unsignedIntegerValue == 1 )
58
- XCTAssert ( MessagePackValue . uint ( 1 ) . unsignedIntegerValue == 1 )
59
- XCTAssert ( MessagePackValue . nil. unsignedIntegerValue == nil )
63
+ func testInt8Value( ) {
64
+ XCTAssert ( MessagePackValue . int ( - 1 ) . int8Value == - 1 )
65
+ XCTAssert ( MessagePackValue . int ( 1 ) . int8Value == 1 )
66
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int8 . min) - 1 ) . int8Value)
67
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int8 . max) + 1 ) . int8Value)
68
+
69
+ XCTAssert ( MessagePackValue . uint ( 1 ) . int8Value == 1 )
70
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( Int8 . max) + 1 ) . int8Value)
71
+ XCTAssertNil ( MessagePackValue . nil. int8Value)
72
+ }
73
+
74
+ func testInt16Value( ) {
75
+ XCTAssert ( MessagePackValue . int ( - 1 ) . int16Value == - 1 )
76
+ XCTAssert ( MessagePackValue . int ( 1 ) . int16Value == 1 )
77
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int16 . min) - 1 ) . int16Value)
78
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int16 . max) + 1 ) . int16Value)
79
+
80
+ XCTAssert ( MessagePackValue . uint ( 1 ) . int16Value == 1 )
81
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( Int16 . max) + 1 ) . int16Value)
82
+ XCTAssertNil ( MessagePackValue . nil. int16Value)
83
+ }
84
+
85
+ func testInt32Value( ) {
86
+ XCTAssert ( MessagePackValue . int ( - 1 ) . int32Value == - 1 )
87
+ XCTAssert ( MessagePackValue . int ( 1 ) . int32Value == 1 )
88
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int32 . min) - 1 ) . int32Value)
89
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( Int32 . max) + 1 ) . int32Value)
90
+
91
+ XCTAssert ( MessagePackValue . uint ( 1 ) . int32Value == 1 )
92
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( Int32 . max) + 1 ) . int32Value)
93
+ XCTAssertNil ( MessagePackValue . nil. int32Value)
94
+ }
95
+
96
+ func testInt64Value( ) {
97
+ XCTAssert ( MessagePackValue . int ( - 1 ) . int64Value == - 1 )
98
+ XCTAssert ( MessagePackValue . int ( 1 ) . int64Value == 1 )
99
+
100
+ XCTAssert ( MessagePackValue . uint ( 1 ) . int64Value == 1 )
101
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( Int64 . max) + 1 ) . int64Value)
102
+ XCTAssertNil ( MessagePackValue . nil. int64Value)
103
+ }
104
+
105
+ func testUIntValue( ) {
106
+ XCTAssert ( MessagePackValue . uint ( 1 ) . uintValue == 1 )
107
+
108
+ XCTAssertNil ( MessagePackValue . int ( - 1 ) . uintValue)
109
+ XCTAssert ( MessagePackValue . int ( 1 ) . uintValue == 1 )
110
+ XCTAssertNil ( MessagePackValue . nil. uintValue)
111
+ }
112
+
113
+ func testUInt8Value( ) {
114
+ XCTAssert ( MessagePackValue . uint ( 1 ) . uint8Value == 1 )
115
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( UInt8 . max) + 1 ) . uint8Value)
116
+
117
+ XCTAssertNil ( MessagePackValue . int ( - 1 ) . uint8Value)
118
+ XCTAssert ( MessagePackValue . int ( 1 ) . uint8Value == 1 )
119
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( UInt8 . max) + 1 ) . uint8Value)
120
+ XCTAssertNil ( MessagePackValue . nil. uint8Value)
121
+ }
122
+
123
+ func testUInt16Value( ) {
124
+ XCTAssert ( MessagePackValue . uint ( 1 ) . uint16Value == 1 )
125
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( UInt16 . max) + 1 ) . uint16Value)
126
+
127
+ XCTAssertNil ( MessagePackValue . int ( - 1 ) . uint16Value)
128
+ XCTAssert ( MessagePackValue . int ( 1 ) . uint16Value == 1 )
129
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( UInt16 . max) + 1 ) . uint16Value)
130
+ XCTAssertNil ( MessagePackValue . nil. uint16Value)
131
+ }
132
+
133
+ func testUInt32Value( ) {
134
+ XCTAssert ( MessagePackValue . uint ( 1 ) . uint32Value == 1 )
135
+ XCTAssertNil ( MessagePackValue . uint ( UInt64 ( UInt32 . max) + 1 ) . uint32Value)
136
+
137
+ XCTAssertNil ( MessagePackValue . int ( - 1 ) . uint32Value)
138
+ XCTAssert ( MessagePackValue . int ( 1 ) . uint32Value == 1 )
139
+ XCTAssertNil ( MessagePackValue . int ( Int64 ( UInt32 . max) + 1 ) . uint32Value)
140
+ XCTAssertNil ( MessagePackValue . nil. uint32Value)
141
+ }
142
+
143
+ func testUInt64Value( ) {
144
+ XCTAssert ( MessagePackValue . uint ( 1 ) . uint64Value == 1 )
145
+
146
+ XCTAssertNil ( MessagePackValue . int ( - 1 ) . uint64Value)
147
+ XCTAssert ( MessagePackValue . int ( 1 ) . uint64Value == 1 )
148
+ XCTAssertNil ( MessagePackValue . nil. uint8Value)
60
149
}
61
150
62
151
func testArrayValue( ) {
@@ -80,8 +169,7 @@ class ConveniencePropertiesTests: XCTestCase {
80
169
XCTAssertEqual ( floatValue!, 3.14 , accuracy: 0.0001 )
81
170
82
171
floatValue = MessagePackValue . double ( 3.14 ) . floatValue
83
- XCTAssertNotNil ( floatValue)
84
- XCTAssertEqual ( floatValue!, 3.14 , accuracy: 0.0001 )
172
+ XCTAssertNil ( floatValue)
85
173
}
86
174
87
175
func testDoubleValue( ) {
0 commit comments