func testFloatDoubleDecoding()

in PlaygroundLogger/PlaygroundLoggerTests/LegacyPlaygroundLoggerTests.swift [449:486]


    func testFloatDoubleDecoding() {
        let f: Float = 1.25
        let d: Double = 1.25
        let f_ld = legacyLog(instance: f, name: "f", id: 0, startLine: 0, endLine: 0, startColumn: 0, endColumn: 0) as! NSData
        let d_ld = legacyLog(instance: d, name: "d", id: 0, startLine: 0, endLine: 0, startColumn: 0, endColumn: 0) as! NSData
        guard let f_dc = legacyLogDecode(f_ld) else {
            XCTFail("Failed to decode log data")
            return
        }
        guard let d_dc = legacyLogDecode(d_ld) else {
            XCTFail("Failed to decode log data")
            return
        }
        
        guard let f_repr = f_dc.object as? PlaygroundDecodedObject_IDERepr else {
            XCTFail("Decoded object is not IDERepr")
            return
        }
        guard let d_repr = d_dc.object as? PlaygroundDecodedObject_IDERepr else {
            XCTFail("Decoded object is not IDERepr")
            return
        }
        
        XCTAssertEqual(f_repr.tag, "FLOT")
        XCTAssertEqual(d_repr.tag, "DOBL")
        
        guard let f2 = f_repr.payload as? Float else {
            XCTFail("Payload is not expected type")
            return
        }
        guard let d2 = d_repr.payload as? Double else {
            XCTFail("Payload is not expected type")
            return
        }
        
        XCTAssertEqual(f, f2)
        XCTAssertEqual(d, d2)
    }