當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tman.it函數代碼示例

本文整理匯總了TypeScript中tman.it函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript it函數的具體用法?TypeScript it怎麽用?TypeScript it使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了it函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: suite

suite('BLOCKED Frame', function () {
  it('new BlockedFrame with StreamID', function () {
    const streamID = new StreamID(10)
    const blockedFrame = new BlockedFrame(streamID)

    strictEqual(blockedFrame.type, 5)
    const buf = toBuffer(blockedFrame)
    ok(buf.equals(bufferFromBytes([
      0x05,
      0x00, 0x00, 0x00, 0x0a,
    ])))
    ok(buf.equals(toBuffer(BlockedFrame.fromBuffer(new BufferVisitor(buf)))))
  })

  it('parse with parseFrame', function () {
    const streamID = new StreamID(10)
    const blockedFrame = new BlockedFrame(streamID)

    strictEqual(blockedFrame.type, 5)
    const buf = toBuffer(blockedFrame)
    ok(buf.equals(bufferFromBytes([
      0x05,
      0x00, 0x00, 0x00, 0x0a,
    ])))
    ok(buf.equals(toBuffer(parseFrame(new BufferVisitor(buf), new PacketNumber(1)))))
  })
})
開發者ID:toajs,項目名稱:quic,代碼行數:27,代碼來源:blocked.ts

示例2: suite

suite('WINDOW_UPDATE Frame', function () {
  it('new WindowUpdateFrame with StreamID', function () {
    const streamID = new StreamID(10)
    const offset = Offset.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0xff, 0xff, 0xff])), 4)
    const windowUpdateFrame = new WindowUpdateFrame(streamID, offset)

    strictEqual(windowUpdateFrame.type, 4)
    const buf = toBuffer(windowUpdateFrame)
    ok(buf.equals(bufferFromBytes([
      0x04,
      0x00, 0x00, 0x00, 0x0a,
      0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
    ])))
    ok(buf.equals(toBuffer(WindowUpdateFrame.fromBuffer(new BufferVisitor(buf)))))
  })

  it('parse with parseFrame', function () {
    const streamID = new StreamID(10)
    const offset = Offset.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0xff, 0xff, 0xff])), 4)
    const windowUpdateFrame = new WindowUpdateFrame(streamID, offset)

    strictEqual(windowUpdateFrame.type, 4)
    const buf = toBuffer(windowUpdateFrame)
    ok(buf.equals(bufferFromBytes([
      0x04,
      0x00, 0x00, 0x00, 0x0a,
      0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
    ])))
    ok(buf.equals(toBuffer(parseFrame(new BufferVisitor(buf), new PacketNumber(1)))))
  })
})
開發者ID:toajs,項目名稱:quic,代碼行數:31,代碼來源:window_update.ts

示例3: suite

  suite('NegotiationPacket', function () {
    it('fromBuffer and toBuffer', function () {
      const connectionID = ConnectionID.random()
      const negotiationPacket = NegotiationPacket.fromConnectionID(connectionID)
      deepEqual(negotiationPacket.versions, getVersions())
      ok(isSupportedVersion(negotiationPacket.versions[0]))

      const buf = toBuffer(negotiationPacket)
      const res = NegotiationPacket.fromBuffer(new BufferVisitor(buf))
      ok(res instanceof NegotiationPacket)
      ok(negotiationPacket.flag === res.flag)
      ok(negotiationPacket.connectionID.equals(res.connectionID))
      deepEqual(negotiationPacket.versions, res.versions)
    })

    it('parse with parsePacket', function () {
      const connectionID = ConnectionID.random()
      const negotiationPacket = NegotiationPacket.fromConnectionID(connectionID)
      deepEqual(negotiationPacket.versions, getVersions())
      ok(isSupportedVersion(negotiationPacket.versions[0]))

      const buf = toBuffer(negotiationPacket)
      const res = parsePacket(new BufferVisitor(buf), SessionType.SERVER) as NegotiationPacket
      ok(res instanceof NegotiationPacket)
      ok(negotiationPacket.flag === res.flag)
      ok(negotiationPacket.connectionID.equals(res.connectionID))
      deepEqual(negotiationPacket.versions, res.versions)
    })
  })
開發者ID:toajs,項目名稱:quic,代碼行數:29,代碼來源:packet.ts

示例4: suite

  suite('check if ACK frame acks a certain packet', function () {
    it('works with an ACK without any ranges', function () {
      const frame = new AckFrame()
      frame.largestAcked = 10
      frame.lowestAcked = 5
      strictEqual(frame.acksPacket(1), false)
      strictEqual(frame.acksPacket(4), false)
      strictEqual(frame.acksPacket(5), true)
      strictEqual(frame.acksPacket(8), true)
      strictEqual(frame.acksPacket(10), true)
      strictEqual(frame.acksPacket(11), false)
      strictEqual(frame.acksPacket(20), false)
    })

    it('works with an ACK with multiple ACK ranges', function () {
      const frame = new AckFrame()
      frame.largestAcked = 20
      frame.lowestAcked = 5
      frame.ackRanges.push(
        new AckRange(15, 20),
        new AckRange(5, 8),
      )
      strictEqual(frame.acksPacket(4), false)
      strictEqual(frame.acksPacket(5), true)
      strictEqual(frame.acksPacket(7), true)
      strictEqual(frame.acksPacket(8), true)
      strictEqual(frame.acksPacket(9), false)
      strictEqual(frame.acksPacket(14), false)
      strictEqual(frame.acksPacket(15), true)
      strictEqual(frame.acksPacket(18), true)
      strictEqual(frame.acksPacket(20), true)
      strictEqual(frame.acksPacket(21), false)
    })
  })
開發者ID:toajs,項目名稱:quic,代碼行數:34,代碼來源:ack.ts

示例5: suite

  suite('SocketAddress', function () {
    it('SocketAddress, IPv4', function () {
      let socketAddress = new SocketAddress(
        { port: 3000, family: 'IPv4', address: '127.0.0.1' })
      const res = SocketAddress.fromBuffer(new BufferVisitor(toBuffer(socketAddress)))
      ok(socketAddress.equals(res))

      socketAddress = new SocketAddress(
        { port: 0x1234, family: 'IPv4', address: '4.31.198.44' })
      ok(toBuffer(socketAddress).equals(bufferFromBytes([
        0x00, 0x02, 0x04, 0x1f, 0xc6, 0x2c, 0x12, 0x34])))
    })

    it('SocketAddress, IPv6', function () {
      let socketAddress = new SocketAddress(
        { port: 65534, family: 'IPv6', address: '::1' })
      strictEqual(socketAddress.address, '0:0:0:0:0:0:0:1')
      const res = SocketAddress.fromBuffer(new BufferVisitor(toBuffer(socketAddress)))
      ok(socketAddress.equals(res))

      socketAddress = new SocketAddress({
        address: '2001:700:300:1800::', family: 'IPv6', port: 0x5678})
      strictEqual(socketAddress.address, '2001:700:300:1800:0:0:0:0')
      ok(socketAddress.equals(SocketAddress.fromBuffer(new BufferVisitor(toBuffer(socketAddress)))))

      socketAddress = new SocketAddress({
        address: '2001:700:300:1800::f', family: 'IPv6', port: 0x5678})
      ok(toBuffer(socketAddress).equals(bufferFromBytes([
        0x00, 0x0a,
        0x20, 0x01, 0x07, 0x00, 0x03, 0x00, 0x18, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
        0x56, 0x78])))
    })
  })
開發者ID:toajs,項目名稱:quic,代碼行數:34,代碼來源:protocol.ts

示例6: suite

suite('STOP_WAITING Frame', function () {
  it('new StopWaitingFrame', function () {
    const headerPacketNumber = PacketNumber.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0x1f])), 2)
    const leastUnacked = PacketNumber.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0x0f])), 2).valueOf()
    const stopWaitingFrame = new StopWaitingFrame(headerPacketNumber, leastUnacked)

    strictEqual(stopWaitingFrame.type, 6)
    strictEqual(leastUnacked, stopWaitingFrame.leastUnacked)
    const buf = toBuffer(stopWaitingFrame)
    ok(buf.equals(bufferFromBytes([
      0x06,
      0x00, 0x10,
    ])))
    ok(buf.equals(toBuffer(StopWaitingFrame.fromBuffer(new BufferVisitor(buf), headerPacketNumber))))
  })

  it('parse with parseFrame', function () {
    const headerPacketNumber = PacketNumber.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0x1f])), 2)
    const leastUnacked = PacketNumber.fromBuffer(new BufferVisitor(bufferFromBytes([0xff, 0x0f])), 2).valueOf()
    const stopWaitingFrame = new StopWaitingFrame(headerPacketNumber, leastUnacked)

    strictEqual(stopWaitingFrame.type, 6)
    strictEqual(leastUnacked, stopWaitingFrame.leastUnacked)
    const buf = toBuffer(stopWaitingFrame)
    ok(buf.equals(bufferFromBytes([
      0x06,
      0x00, 0x10,
    ])))
    ok(buf.equals(toBuffer(parseFrame(new BufferVisitor(buf), headerPacketNumber))))
  })
})
開發者ID:toajs,項目名稱:quic,代碼行數:31,代碼來源:stop_waiting.ts

示例7: suite

  suite('UnsafeUInt', function () {
    it('should work', function () {
      let buf = bufferFromBytes([0x1])
      let val = readUnsafeUInt(buf, 0, 1)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(1), val, 0, 1)))

      buf = bufferFromBytes([0x0, 0x1])
      val = readUnsafeUInt(buf, 0, 2)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(2), val, 0, 2)))

      buf = bufferFromBytes([0x0, 0x0, 0x1])
      val = readUnsafeUInt(buf, 0, 3)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(3), val, 0, 3)))

      buf = bufferFromBytes([0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      val = readUnsafeUInt(buf, 0, 6)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(6), val, 0, 6)))

      buf = bufferFromBytes([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      val = readUnsafeUInt(buf, 0, 7)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(7), val, 0, 7)))

      buf = bufferFromBytes([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      val = readUnsafeUInt(buf, 0, 8)
      strictEqual(val, 1)
      ok(buf.equals(writeUnsafeUInt(Buffer.allocUnsafe(8), val, 0, 8)))

      buf = bufferFromBytes([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      strictEqual(readUnsafeUInt(buf, 1, 6), 1)

      buf = bufferFromBytes([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      strictEqual(readUnsafeUInt(buf, 1, 7), 1)

      buf = bufferFromBytes([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1])
      strictEqual(readUnsafeUInt(buf, 1, 8), 1)
    })

    it('should work for Number.MAX_SAFE_INTEGER', function () {
      const val = Number.MAX_SAFE_INTEGER
      let buf = writeUnsafeUInt(Buffer.allocUnsafe(7), val, 0, 7)
      strictEqual(readUnsafeUInt(buf, 0, 7), val)

      buf = writeUnsafeUInt(Buffer.allocUnsafe(8), val, 0, 8)
      strictEqual(readUnsafeUInt(buf, 0, 8), val)

      buf = writeUnsafeUInt(Buffer.allocUnsafe(8), val, 1, 7)
      strictEqual(readUnsafeUInt(buf, 1, 7), val)
    })
  })
開發者ID:toajs,項目名稱:quic,代碼行數:54,代碼來源:common.ts


注:本文中的tman.it函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。