mirror of
https://github.com/google/flatbuffers.git
synced 2026-11-14 07:56:22 +00:00
Bigfoot
This commit is contained in:
@@ -16,19 +16,17 @@
|
||||
|
||||
import Common
|
||||
import FlexBuffers
|
||||
import Foundation
|
||||
import Testing
|
||||
import XCTest
|
||||
|
||||
struct FlexBuffersJSONTests {
|
||||
@Test
|
||||
final class FlexBuffersJSONTests: XCTestCase {
|
||||
func testEncodingJSON() throws {
|
||||
let buf: ByteBuffer = createProperBuffer().sizedByteBuffer
|
||||
let reference = try getRoot(buffer: buf)!
|
||||
|
||||
let json = reference.jsonString()
|
||||
// swiftformat:disable all
|
||||
#expect(
|
||||
json ==
|
||||
XCTAssertEqual(
|
||||
json,
|
||||
"{\"bar\": [1, 2, 3], \"bar3\": [1, 2, 3], \"bool\": true, \"bools\": [true, false, true, false], \"foo\": 100.0, \"mymap\": {\"foo\": \"Fred\"}, \"vec\": [-100, \"Fred\", 4.0, \"M\", false, 4.0]}"
|
||||
)
|
||||
// swiftformat:enable all
|
||||
@@ -39,15 +37,15 @@ struct FlexBuffersJSONTests {
|
||||
with: data,
|
||||
options: []) as! [String: Any]
|
||||
|
||||
#expect(decodedData["bar"] as! [Int] == [1, 2, 3])
|
||||
#expect(decodedData["bar3"] as! [Int] == [1, 2, 3])
|
||||
XCTAssertEqual(decodedData["bar"] as! [Int], [1, 2, 3])
|
||||
XCTAssertEqual(decodedData["bar3"] as! [Int], [1, 2, 3])
|
||||
|
||||
let vec: [Any] = decodedData["vec"] as! [Any]
|
||||
#expect(vec[0] as! Int == -100)
|
||||
#expect(vec[1] as! String == "Fred")
|
||||
#expect(vec[2] as! Double == 4.0)
|
||||
#expect(vec[3] as! String == "M")
|
||||
#expect(vec[4] as! Bool == false)
|
||||
#expect(vec[5] as! Double == 4.0)
|
||||
XCTAssertEqual(vec[0] as! Int, -100)
|
||||
XCTAssertEqual(vec[1] as! String, "Fred")
|
||||
XCTAssertEqual(vec[2] as! Double, 4.0)
|
||||
XCTAssertEqual(vec[3] as! String, "M")
|
||||
XCTAssertEqual(vec[4] as! Bool, false)
|
||||
XCTAssertEqual(vec[5] as! Double, 4.0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user