mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-28 21:43:44 +08:00
f8e13417f2
date: 2026-08-15T14:20:10 master commit: d48cfa730bf21593b684efeaf3fd8940695e1dea
22 lines
585 B
Python
22 lines
585 B
Python
import unittest
|
|
from tinygrad import Tensor
|
|
from tinygrad.nn.state import TensorIO
|
|
|
|
class TestTensorIO(unittest.TestCase):
|
|
def test_read(self):
|
|
data = b"Hello World!"
|
|
fobj = TensorIO(Tensor(data))
|
|
self.assertEqual(fobj.read(1), data[:1])
|
|
self.assertEqual(fobj.read(5), data[1:6])
|
|
self.assertEqual(fobj.read(100), data[6:])
|
|
self.assertEqual(fobj.read(100), b"")
|
|
|
|
def test_read_nolen(self):
|
|
data = b"Hello World!"
|
|
fobj = TensorIO(Tensor(data))
|
|
fobj.seek(2)
|
|
self.assertEqual(fobj.read(), data[2:])
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|