Explicitly test \n and \r\n files
\r\n files must be working due to micropython's built in handling of text-mode files, I didn't implement it. \r-only (old mac text-mode files) are explicitly not supported by the toml format.
This commit is contained in:
parent
f6b69cf5e3
commit
337b1da143
|
@ -35,7 +35,7 @@ bdev = RAMBlockDevice(64)
|
|||
uos.VfsFat.mkfs(bdev)
|
||||
uos.mount(uos.VfsFat(bdev), "/")
|
||||
|
||||
content_good = """
|
||||
content_good = b"""
|
||||
# comment
|
||||
key0 = "hello world"
|
||||
key1 = 7
|
||||
|
@ -54,15 +54,15 @@ subvalue = "hi"
|
|||
"""
|
||||
|
||||
content_bad = [
|
||||
'key = "\n',
|
||||
'key = """\n',
|
||||
"key =\n",
|
||||
'key="',
|
||||
b'key = "\n',
|
||||
b'key = """\n',
|
||||
b"key =\n",
|
||||
b'key="',
|
||||
]
|
||||
|
||||
|
||||
def run_test(key, content):
|
||||
with open("/settings.toml", "w") as f:
|
||||
with open("/settings.toml", "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
try:
|
||||
|
@ -72,11 +72,15 @@ def run_test(key, content):
|
|||
print(key, str(e))
|
||||
|
||||
|
||||
for i in range(13):
|
||||
run_test(f"key{i}", content_good)
|
||||
|
||||
content_good = content_good.replace(b"\n", b"\r\n")
|
||||
for i in range(13):
|
||||
run_test(f"key{i}", content_good)
|
||||
|
||||
# Test value without trailing newline
|
||||
run_test(f"noeol", "noeol=3")
|
||||
run_test(f"noeol", b"noeol=3")
|
||||
|
||||
for content in content_bad:
|
||||
run_test("key", content)
|
||||
|
|
|
@ -11,6 +11,19 @@ key9 'hello comment'
|
|||
key10 127
|
||||
key11 0
|
||||
key12 None
|
||||
key0 'hello world'
|
||||
key1 7
|
||||
key2 Invalid byte '\n'
|
||||
key3 'Áx'
|
||||
key4 'Áx'
|
||||
key5 Invalid byte '\\'
|
||||
key6 '\t\r\x08'
|
||||
key7 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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