当前位置: 首页>>代码示例>>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;未经允许,请勿转载。