Example #1
0
 def test_typed(self) -> None:
     x = IOBuf(array.array("l", [1, 2, 3, 4, 5]))  # type: ignore
     self.assertEqual(x.chain_size(), 5 * struct.calcsize("l"))
Example #2
0
 def test_unshaped(self) -> None:
     x = IOBuf(memoryview(b"a").cast("B", shape=[]))  # type: ignore
     self.assertEqual(x.chain_size(), 1)
Example #3
0
 def test_multidimensional(self) -> None:
     x = IOBuf(memoryview(b"abcdef").cast("B", shape=[3,
                                                      2]))  # type: ignore
     self.assertEqual(x.chain_size(), 6)
Example #4
0
 def test_typed(self) -> None:
     # pyre-fixme[6]: Expected `Union[IOBuf, bytearray, bytes, memoryview]` for
     #  1st param but got `array[int]`.
     x = IOBuf(array.array("l", [1, 2, 3, 4, 5]))
     self.assertEqual(x.chain_size(), 5 * struct.calcsize("l"))