Skip to content

Commit 15a1d04

Browse files
authored
Merge pull request #1 from Cosmo/swift3
Swift3
2 parents bb5acb1 + 88a6d27 commit 15a1d04

16 files changed

+1452
-16
lines changed

.gitignore

+66
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,68 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
14

5+
## Build generated
6+
build/
7+
DerivedData/
8+
9+
## Various settings
10+
*.pbxuser
11+
!default.pbxuser
12+
*.mode1v3
13+
!default.mode1v3
14+
*.mode2v3
15+
!default.mode2v3
16+
*.perspectivev3
17+
!default.perspectivev3
18+
xcuserdata/
19+
20+
## Other
21+
*.moved-aside
22+
*.xcuserstate
23+
24+
## Obj-C/Swift specific
25+
*.hmap
26+
*.ipa
27+
*.dSYM.zip
28+
*.dSYM
29+
30+
## macOS specific
31+
.DS_Store
32+
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
36+
37+
# Swift Package Manager
38+
#
39+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40+
# Packages/
241
.build/
42+
43+
# CocoaPods
44+
#
45+
# We recommend against adding the Pods directory to your .gitignore. However
46+
# you should judge for yourself, the pros and cons are mentioned at:
47+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
48+
#
49+
# Pods/
50+
51+
# Carthage
52+
#
53+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
54+
# Carthage/Checkouts
55+
56+
Carthage/Build
57+
58+
# fastlane
59+
#
60+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
61+
# screenshots whenever they are needed.
62+
# For more information about the recommended setup visit:
63+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
64+
65+
fastlane/report.xml
66+
fastlane/Preview.html
67+
fastlane/screenshots
68+
fastlane/test_output
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
//
2+
// BinaryKit_iOSTests.swift
3+
// BinaryKit-iOSTests
4+
//
5+
// Created by Devran Uenal on 11.9.16.
6+
//
7+
//
8+
9+
import XCTest
10+
import BinaryKit
11+
12+
class BinaryKit_iOSTests: XCTestCase {
13+
override func setUp() {
14+
super.setUp()
15+
}
16+
17+
override func tearDown() {
18+
super.tearDown()
19+
}
20+
21+
func testBit0() {
22+
var binary = Binary(bytes: [0xDE, 0xAD])
23+
let bit0 = binary.next(bits: 1)
24+
XCTAssertEqual(bit0, 1)
25+
}
26+
27+
func testBit1() {
28+
var binary = Binary(bytes: [0xDE, 0xAD])
29+
let _ = binary.next(bits: 1)
30+
let bit1 = binary.next(bits: 1)
31+
XCTAssertEqual(bit1, 1)
32+
}
33+
34+
func testBit2() {
35+
var binary = Binary(bytes: [0xDE, 0xAD])
36+
let _ = binary.next(bits: 1)
37+
let _ = binary.next(bits: 1)
38+
let bit2 = binary.next(bits: 1)
39+
XCTAssertEqual(bit2, 0)
40+
}
41+
42+
func testBit3() {
43+
var binary = Binary(bytes: [0xDE, 0xAD])
44+
let _ = binary.next(bits: 1)
45+
let _ = binary.next(bits: 1)
46+
let _ = binary.next(bits: 1)
47+
let bit3 = binary.next(bits: 1)
48+
XCTAssertEqual(bit3, 1)
49+
}
50+
51+
func testBit4And5() {
52+
var binary = Binary(bytes: [0xDE, 0xAD])
53+
let _ = binary.next(bits: 1)
54+
let _ = binary.next(bits: 1)
55+
let _ = binary.next(bits: 1)
56+
let _ = binary.next(bits: 1)
57+
let bits4And5 = binary.next(bits: 2)
58+
XCTAssertEqual(bits4And5, 3)
59+
}
60+
61+
func testBit6And7() {
62+
var binary = Binary(bytes: [0xDE, 0xAD])
63+
let _ = binary.next(bits: 1)
64+
let _ = binary.next(bits: 1)
65+
let _ = binary.next(bits: 1)
66+
let _ = binary.next(bits: 1)
67+
let _ = binary.next(bits: 2)
68+
let bits6And7 = binary.next(bits: 2)
69+
XCTAssertEqual(bits6And7, 2)
70+
}
71+
72+
func testByte1() {
73+
var binary = Binary(bytes: [0xDE, 0xAD])
74+
let _ = binary.next(bits: 1)
75+
binary.readingOffset = 0
76+
let bytes0and1 = binary.next(bytes: 2)
77+
XCTAssertEqual(bytes0and1, [222, 173])
78+
}
79+
80+
func testBitByPosition() {
81+
var binary = Binary(bytes: [0xDE, 0xAD])
82+
let _ = binary.next(bits: 1)
83+
binary.readingOffset = 0
84+
let bit5 = binary.bit(5)
85+
XCTAssertEqual(bit5, 1)
86+
}
87+
88+
func testByteByPosition() {
89+
var binary = Binary(bytes: [0xDE, 0xAD])
90+
let _ = binary.next(bits: 1)
91+
binary.readingOffset = 0
92+
let _ = binary.bit(5)
93+
let byte1 = binary.byte(1)
94+
XCTAssertEqual(byte1, 173)
95+
}
96+
97+
func testFirst16Bits() {
98+
var binary = Binary(bytes: [0xDE, 0xAD])
99+
let _ = binary.next(bits: 1)
100+
binary.readingOffset = 0
101+
let _ = binary.bit(5)
102+
let _ = binary.byte(1)
103+
let first16Bits = binary.bits(0, 16)
104+
XCTAssertEqual(first16Bits, 57005)
105+
}
106+
107+
func testFirstTwoBytes() {
108+
var binary = Binary(bytes: [0xDE, 0xAD])
109+
let _ = binary.next(bits: 1)
110+
binary.readingOffset = 0
111+
let _ = binary.bit(5)
112+
let _ = binary.byte(1)
113+
let _ = binary.bits(0, 16)
114+
let firstTwoBytes = binary.bytes(0, 2) as Int
115+
XCTAssertEqual(firstTwoBytes, 57005)
116+
}
117+
}

BinaryKit-iOSTests/Info.plist

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

BinaryKit.xcodeproj/BinaryKit.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)