@@ -5,19 +5,47 @@ class BlobTests: XCTestCase {
55
66 func test_toHex( ) {
77 let blob = Blob ( bytes: [ 0 , 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 150 , 250 , 255 ] )
8-
98 XCTAssertEqual ( blob. toHex ( ) , " 000a141e28323c46505a6496faff " )
109 }
1110
11+ func test_toHex_empty( ) {
12+ let blob = Blob ( bytes: [ ] )
13+ XCTAssertEqual ( blob. toHex ( ) , " " )
14+ }
15+
16+ func test_description( ) {
17+ let blob = Blob ( bytes: [ 0 , 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 150 , 250 , 255 ] )
18+ XCTAssertEqual ( blob. description, " x'000a141e28323c46505a6496faff' " )
19+ }
20+
21+ func test_description_empty( ) {
22+ let blob = Blob ( bytes: [ ] )
23+ XCTAssertEqual ( blob. description, " x'' " )
24+ }
25+
1226 func test_init_array( ) {
13- let blob = Blob ( bytes: [ 42 , 42 , 42 ] )
14- XCTAssertEqual ( blob. bytes , [ 42 , 42 , 42 ] )
27+ let blob = Blob ( bytes: [ 42 , 43 , 44 ] )
28+ XCTAssertEqual ( [ UInt8 ] ( blob. data ) , [ 42 , 43 , 44 ] )
1529 }
1630
1731 func test_init_unsafeRawPointer( ) {
1832 let pointer = UnsafeMutablePointer< UInt8> . allocate( capacity: 3 )
1933 pointer. initialize ( repeating: 42 , count: 3 )
2034 let blob = Blob ( bytes: pointer, length: 3 )
21- XCTAssertEqual ( blob. bytes, [ 42 , 42 , 42 ] )
35+ XCTAssertEqual ( [ UInt8] ( blob. data) , [ 42 , 42 , 42 ] )
36+ }
37+
38+ func test_equality( ) {
39+ let blob1 = Blob ( bytes: [ 42 , 42 , 42 ] )
40+ let blob2 = Blob ( bytes: [ 42 , 42 , 42 ] )
41+ let blob3 = Blob ( bytes: [ 42 , 42 , 43 ] )
42+
43+ XCTAssertEqual ( Blob ( bytes: [ ] ) , Blob ( bytes: [ ] ) )
44+ XCTAssertEqual ( blob1, blob2)
45+ XCTAssertNotEqual ( blob1, blob3)
46+ }
47+
48+ func XXX_test_init_with_mutable_data_fails( ) {
49+ _ = Blob ( data: NSMutableData ( ) )
2250 }
2351}
0 commit comments