mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 01:18:05 +00:00
* [Swift] FlatBuffers createMonster method doesn't treat struct properly This PR fixed a issue where a struct is not treated properly when use create inside. A example would be the pos inside Monster. The createMonster method takes an Offset for pos. However, FlatBuffersBuilder.add(struct:) doesn't really take Offset argument. That means we don't really add a struct at all for Monster. It will show up as the pos never set. This doesn't show up in FlatBuffersMonsterWriterTests.swift because it implements its own createMonster method, which happens do the dance properly (i.e. first call create(struct) and then immediately call add:). This PR modified the `add(pos:)` interface such that it takes the UnsafeMutableRawPointer directly, calling `create(struct:)` under the hood. I can add unit tests once the direction of this PR approved. * Fix object api pack method codegen. * Add unit tests that uses Monster.createMonster method to serialize. * Updated sample_binary.swift
100 lines
4.0 KiB
Swift
100 lines
4.0 KiB
Swift
#if !canImport(ObjectiveC)
|
|
import XCTest
|
|
|
|
extension FlatBuffersDoubleTests {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersDoubleTests = [
|
|
("testCreateCountry", testCreateCountry),
|
|
("testCreateFinish", testCreateFinish),
|
|
("testCreateFinishWithPrefix", testCreateFinishWithPrefix),
|
|
]
|
|
}
|
|
|
|
extension FlatBuffersMonsterWriterTests {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersMonsterWriterTests = [
|
|
("testCreateMonster", testCreateMonster),
|
|
("testCreateMonsterPrefixed", testCreateMonsterPrefixed),
|
|
("testCreateMonsterResizedBuffer", testCreateMonsterResizedBuffer),
|
|
("testCreateMonsterUsingCreateMonsterMethodWithNilPos", testCreateMonsterUsingCreateMonsterMethodWithNilPos),
|
|
("testCreateMonsterUsingCreateMonsterMethodWithPosX", testCreateMonsterUsingCreateMonsterMethodWithPosX),
|
|
("testData", testData),
|
|
("testReadFromOtherLanguages", testReadFromOtherLanguages),
|
|
("testReadMonsterFromUnsafePointerWithoutCopying", testReadMonsterFromUnsafePointerWithoutCopying),
|
|
]
|
|
}
|
|
|
|
extension FlatBuffersStructsTests {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersStructsTests = [
|
|
("testCreatingEnums", testCreatingEnums),
|
|
("testCreatingStruct", testCreatingStruct),
|
|
("testCreatingVectorStruct", testCreatingVectorStruct),
|
|
("testCreatingVectorStructWithForcedDefaults", testCreatingVectorStructWithForcedDefaults),
|
|
("testReadingStruct", testReadingStruct),
|
|
("testReadingStructWithEnums", testReadingStructWithEnums),
|
|
("testWritingAndMutatingBools", testWritingAndMutatingBools),
|
|
]
|
|
}
|
|
|
|
extension FlatBuffersTests {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersTests = [
|
|
("testCreate", testCreate),
|
|
("testCreateFinish", testCreateFinish),
|
|
("testCreateFinishWithPrefix", testCreateFinishWithPrefix),
|
|
("testCreateString", testCreateString),
|
|
("testEndian", testEndian),
|
|
("testOffset", testOffset),
|
|
("testReadCountry", testReadCountry),
|
|
("testStartTable", testStartTable),
|
|
]
|
|
}
|
|
|
|
extension FlatBuffersUnionTests {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersUnionTests = [
|
|
("testCreateMonstor", testCreateMonstor),
|
|
("testEndTableFinish", testEndTableFinish),
|
|
("testEnumVector", testEnumVector),
|
|
("testUnionVector", testUnionVector),
|
|
]
|
|
}
|
|
|
|
extension FlatBuffersVectors {
|
|
// DO NOT MODIFY: This is autogenerated, use:
|
|
// `swift test --generate-linuxmain`
|
|
// to regenerate.
|
|
static let __allTests__FlatBuffersVectors = [
|
|
("testCreateEmptyIntArray", testCreateEmptyIntArray),
|
|
("testCreateIntArray", testCreateIntArray),
|
|
("testCreateSharedStringVector", testCreateSharedStringVector),
|
|
("testCreateVectorOfStrings", testCreateVectorOfStrings),
|
|
("testCreatingTwoCountries", testCreatingTwoCountries),
|
|
("testReadDoubleArray", testReadDoubleArray),
|
|
("testReadInt32Array", testReadInt32Array),
|
|
]
|
|
}
|
|
|
|
public func __allTests() -> [XCTestCaseEntry] {
|
|
return [
|
|
testCase(FlatBuffersDoubleTests.__allTests__FlatBuffersDoubleTests),
|
|
testCase(FlatBuffersMonsterWriterTests.__allTests__FlatBuffersMonsterWriterTests),
|
|
testCase(FlatBuffersStructsTests.__allTests__FlatBuffersStructsTests),
|
|
testCase(FlatBuffersTests.__allTests__FlatBuffersTests),
|
|
testCase(FlatBuffersUnionTests.__allTests__FlatBuffersUnionTests),
|
|
testCase(FlatBuffersVectors.__allTests__FlatBuffersVectors),
|
|
]
|
|
}
|
|
#endif
|