mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-06 00:56:54 +00:00
[Swift] Implements FlatbuffersVector which confirms to RandomAccessCollection (#8752)
* Implements FlatbuffersVector in swift Implements FlatbuffersVector which confirms to RandomAccessCollection, this would give us semi-native sugary syntax to all the arrays in swift port. This work will also be the foundation of using arrays in swift * Fix failing tests for Swift
This commit is contained in:
@@ -99,13 +99,17 @@ final class FlatbuffersVerifierTests: XCTestCase {
|
||||
|
||||
func testVeriferInitPassing() {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: 8, alignment: 1)
|
||||
var buffer = ByteBuffer(assumingMemoryBound: memory, capacity: Int(FlatBufferMaxSize) - 1)
|
||||
var buffer = ByteBuffer(
|
||||
assumingMemoryBound: memory,
|
||||
capacity: Int(FlatBufferMaxSize) - 1)
|
||||
XCTAssertNoThrow(try Verifier(buffer: &buffer))
|
||||
}
|
||||
|
||||
func testVeriferInitFailing() {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: 8, alignment: 1)
|
||||
var buffer = ByteBuffer(assumingMemoryBound: memory, capacity: Int(FlatBufferMaxSize) + 1)
|
||||
var buffer = ByteBuffer(
|
||||
assumingMemoryBound: memory,
|
||||
capacity: Int(FlatBufferMaxSize) + 1)
|
||||
XCTAssertThrowsError(try Verifier(buffer: &buffer))
|
||||
}
|
||||
|
||||
@@ -403,8 +407,8 @@ final class FlatbuffersVerifierTests: XCTestCase {
|
||||
|
||||
private func getOffset(
|
||||
at value: Int,
|
||||
within verifier: Verifier
|
||||
) throws -> Int {
|
||||
within verifier: Verifier) throws -> Int
|
||||
{
|
||||
let offset: UOffset = try verifier.getValue(at: value)
|
||||
return Int(clamping: (Int(offset) &+ 0).magnitude)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user