mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-11 02:33:55 +08:00
0e51ecbb7e
version: sunnypilot v2026.003.000 (dev)
date: 2026-09-09T15:43:49
master commit: b255314f5a
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()
|