1*890232f2SAndroid Build Coastguard Worker /*
2*890232f2SAndroid Build Coastguard Worker  * Copyright 2021 Google Inc. All rights reserved.
3*890232f2SAndroid Build Coastguard Worker  *
4*890232f2SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*890232f2SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*890232f2SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*890232f2SAndroid Build Coastguard Worker  *
8*890232f2SAndroid Build Coastguard Worker  *     http://www.apache.org/licenses/LICENSE-2.0
9*890232f2SAndroid Build Coastguard Worker  *
10*890232f2SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*890232f2SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*890232f2SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*890232f2SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*890232f2SAndroid Build Coastguard Worker  * limitations under the License.
15*890232f2SAndroid Build Coastguard Worker  */
16*890232f2SAndroid Build Coastguard Worker 
17*890232f2SAndroid Build Coastguard Worker import XCTest
18*890232f2SAndroid Build Coastguard Worker @testable import FlatBuffers
19*890232f2SAndroid Build Coastguard Worker 
20*890232f2SAndroid Build Coastguard Worker final class FlatBuffersStructsTests: XCTestCase {
21*890232f2SAndroid Build Coastguard Worker 
testWritingAndMutatingBoolsnull22*890232f2SAndroid Build Coastguard Worker   func testWritingAndMutatingBools() {
23*890232f2SAndroid Build Coastguard Worker     var fbb = FlatBufferBuilder()
24*890232f2SAndroid Build Coastguard Worker     let start = TestMutatingBool.startTestMutatingBool(&fbb)
25*890232f2SAndroid Build Coastguard Worker     TestMutatingBool.add(b: Property(property: false), &fbb)
26*890232f2SAndroid Build Coastguard Worker     let root = TestMutatingBool.endTestMutatingBool(&fbb, start: start)
27*890232f2SAndroid Build Coastguard Worker     fbb.finish(offset: root)
28*890232f2SAndroid Build Coastguard Worker 
29*890232f2SAndroid Build Coastguard Worker     let testMutatingBool = TestMutatingBool
30*890232f2SAndroid Build Coastguard Worker       .getRootAsTestMutatingBool(bb: fbb.sizedBuffer)
31*890232f2SAndroid Build Coastguard Worker     let property = testMutatingBool.mutableB
32*890232f2SAndroid Build Coastguard Worker     XCTAssertEqual(property?.property, false)
33*890232f2SAndroid Build Coastguard Worker     property?.mutate(property: false)
34*890232f2SAndroid Build Coastguard Worker     XCTAssertEqual(property?.property, false)
35*890232f2SAndroid Build Coastguard Worker     property?.mutate(property: true)
36*890232f2SAndroid Build Coastguard Worker     XCTAssertEqual(property?.property, true)
37*890232f2SAndroid Build Coastguard Worker   }
38*890232f2SAndroid Build Coastguard Worker 
39*890232f2SAndroid Build Coastguard Worker }
40*890232f2SAndroid Build Coastguard Worker 
41*890232f2SAndroid Build Coastguard Worker struct Vec: NativeStruct {
42*890232f2SAndroid Build Coastguard Worker   var x: Float32
43*890232f2SAndroid Build Coastguard Worker   var y: Float32
44*890232f2SAndroid Build Coastguard Worker   var z: Float32
45*890232f2SAndroid Build Coastguard Worker }
46