Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ptoffy committed Nov 12, 2024
1 parent 9b8a460 commit daa875b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
container: swift:noble
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint
run: swift-format lint --recursive --strict --parallel .
- name: Build
run: swift build
- name: Test
run: swift test


9 changes: 3 additions & 6 deletions Sources/Bcrypt/Base64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ struct Base64 {
return []
}

var len = count
if len > bytes.count {
len = bytes.count
}
let len = min(bytes.count, count)

var offset: Int = 0
var c1: UInt8
Expand All @@ -51,7 +48,7 @@ struct Base64 {
while offset < len {
c1 = bytes[offset] & 0xff
offset &+= 1
result.append(encodingTable[Int(truncatingIfNeeded: (c1 >> 2) & 0x3f)])
result.append(encodingTable[Int(truncatingIfNeeded: (c1 &>> 2) & 0x3f)])
c1 = (c1 & 0x03) &<< 4
if offset >= len {
result.append(encodingTable[Int(truncatingIfNeeded: c1 & 0x3f)])
Expand Down Expand Up @@ -79,7 +76,7 @@ struct Base64 {
}

private static func char64(of x: UInt8) -> UInt8 {
x > 127 ? 255 : decodingTable[Int(x)]
x > 127 ? 255 : decodingTable[Int(truncatingIfNeeded: x)]
}

@usableFromInline
Expand Down

0 comments on commit daa875b

Please sign in to comment.