mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 03:25:19 +00:00
Extract BLE and chat architecture policies (#1324)
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import bitchat
|
||||
|
||||
struct Base64URLCodingTests {
|
||||
@Test
|
||||
func encodesWithoutPaddingOrURLUnsafeCharacters() {
|
||||
let encoded = Base64URLCoding.encode(Data([0xff, 0xee, 0xdd, 0xcc]))
|
||||
|
||||
#expect(!encoded.contains("="))
|
||||
#expect(!encoded.contains("+"))
|
||||
#expect(!encoded.contains("/"))
|
||||
}
|
||||
|
||||
@Test
|
||||
func decodesUnpaddedValue() throws {
|
||||
let data = try #require(Base64URLCoding.decode("_-7dzA"))
|
||||
|
||||
#expect(data == Data([0xff, 0xee, 0xdd, 0xcc]))
|
||||
}
|
||||
|
||||
@Test
|
||||
func roundTripsData() throws {
|
||||
let original = Data("hello bitchat".utf8)
|
||||
|
||||
let decoded = try #require(Base64URLCoding.decode(Base64URLCoding.encode(original)))
|
||||
|
||||
#expect(decoded == original)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user