test(General): implement unit test for serializer

This commit is contained in:
2025-05-13 15:14:50 +08:00
parent 45357c42a8
commit 44b6a8c3f1
2 changed files with 99 additions and 24 deletions
+5 -2
View File
@@ -18,7 +18,7 @@ def bytes_to_long(b: bytes) -> int:
def read_long(bis: BytesIO) -> int:
try:
return struct.unpack("q", bis.read(8))[0]
except IOError:
except struct.error:
return 0
@@ -51,7 +51,10 @@ def csv_as_list(input_str: str) -> List[str]:
def add_to_map(map_: Dict[str, List[str]], token: str) -> None:
eq_idx = token.index("=")
try:
eq_idx = token.index("=")
except ValueError:
eq_idx = -1 # set to -1 when not found
if eq_idx > 0:
key = token[:eq_idx]
map_[key] = csv_as_list(token[eq_idx + 1 :])