Skip to content

Commit daa875b

Browse files
committed
Add CI
1 parent 9b8a460 commit daa875b

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build and Test
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
container: swift:noble
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Lint
16+
run: swift-format lint --recursive --strict --parallel .
17+
- name: Build
18+
run: swift build
19+
- name: Test
20+
run: swift test
21+
22+

Sources/Bcrypt/Base64.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ struct Base64 {
3838
return []
3939
}
4040

41-
var len = count
42-
if len > bytes.count {
43-
len = bytes.count
44-
}
41+
let len = min(bytes.count, count)
4542

4643
var offset: Int = 0
4744
var c1: UInt8
@@ -51,7 +48,7 @@ struct Base64 {
5148
while offset < len {
5249
c1 = bytes[offset] & 0xff
5350
offset &+= 1
54-
result.append(encodingTable[Int(truncatingIfNeeded: (c1 >> 2) & 0x3f)])
51+
result.append(encodingTable[Int(truncatingIfNeeded: (c1 &>> 2) & 0x3f)])
5552
c1 = (c1 & 0x03) &<< 4
5653
if offset >= len {
5754
result.append(encodingTable[Int(truncatingIfNeeded: c1 & 0x3f)])
@@ -79,7 +76,7 @@ struct Base64 {
7976
}
8077

8178
private static func char64(of x: UInt8) -> UInt8 {
82-
x > 127 ? 255 : decodingTable[Int(x)]
79+
x > 127 ? 255 : decodingTable[Int(truncatingIfNeeded: x)]
8380
}
8481

8582
@usableFromInline

0 commit comments

Comments
 (0)