Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233import Foundationimport Testing@testable import CoreATProtocol
@Suite("Base64URL encoding")struct Base64URLTests { @Test("Data encoding strips padding and swaps alphabet") func dataEncoding() { // Bytes chosen so the standard base64 output contains both + and /. let input = Data([0xfb, 0xff, 0xbf, 0xfe]) #expect(input.base64EncodedString() == "+/+//g==") #expect(input.base64URLEncodedString() == "-_-__g") }
@Test("Empty data round-trips to empty string") func emptyData() { #expect(Data().base64URLEncodedString() == "") }
@Test("String helper rewrites alphabet and strips padding") func stringRewrite() { #expect("+/+//g==".base64URLEncoded() == "-_-__g") #expect("abcd".base64URLEncoded() == "abcd") }
@Test("Variable-length inputs produce unpadded output") func variableLengthInputs() { #expect(Data([0x01]).base64URLEncodedString() == "AQ") #expect(Data([0x01, 0x02]).base64URLEncodedString() == "AQI") #expect(Data([0x01, 0x02, 0x03]).base64URLEncodedString() == "AQID") }}