sup-dolphin-memory-lib/tests/test_memorylib.py
sup39 2527142f07 [v0.1.0] pack into one PyPI package
Complete all basic functions, including:
- find dolphin, init shared memory
- read/write raw bytes
- read/write struct
- read/write single value (uint32/16/8, int32/16/8, float)
2022-06-25 03:23:12 +09:00

27 lines
785 B
Python

import unittest
from dolphin.memorylib import Dolphin
class TestMemorylib(unittest.TestCase):
def test_rw_uint32(self):
dolphin = Dolphin()
import multiprocessing
self.assertIsNotNone(dolphin.hook(), msg='No game is running')
from random import randint
from timeit import default_timer
start = default_timer()
print("Testing Shared Memory Method")
start = default_timer()
count = 500000
for i in range(count):
value = randint(0, 2**32-1)
dolphin.write_uint32(0x80000000, value)
result = dolphin.read_uint32(0x80000000)
self.assertEqual(result, value)
diff = default_timer()-start
print(count/diff, "per sec")
print("time: ", diff)
if __name__ == '__main__':
unittest.main()