Files
StarPilot/openpilot/starpilot/flm/tests/test_identity.py
T
firestar5683 200632aabd StarPilot Auto Learn
Learn bounded feed-forward corrections on eligible torque controllers behind Use StarPilot Auto Learn, preserving installed tunes and native safety limits.
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: haraschax <6804392+haraschax@users.noreply.github.com>
Co-authored-by: pharmacomaniac <blittle65@gmail.com>

Co-authored-by: whoisdomi <dcantu83@gmail.com>
2026-10-14 20:02:39 -05:00

29 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import random
import unittest
from openpilot.starpilot.flm.fullrate_collector import identity
class TestIdentity(unittest.TestCase):
def test_exact_lowercase_hex_language(self):
allowed = '0123456789abcdef'
base = 'a' * 64
for code in range(256):
character = chr(code)
for position in range(64):
value = base[:position] + character + base[position + 1:]
self.assertIs(identity(value), character in allowed)
randomizer = random.Random(64)
for _ in range(1000):
self.assertIs(identity(''.join(randomizer.choice(allowed) for _ in range(64))), True)
def test_strict_types_lengths_and_unicode(self):
class StringSubclass(str):
pass
for value in (None, False, 0, b'a' * 64, bytearray(b'a' * 64), StringSubclass('a' * 64)):
self.assertIs(identity(value), False)
for length in (0, 1, 63, 65, 10000):
self.assertIs(identity('a' * length), False)
for character in ('\n', '\0', 'é', 'A', '𝟢', '٠', '\ud800'):
self.assertIs(identity('a' * 63 + character), False)