test that data+parity isn't > 65536

This commit is contained in:
Dmitriy Ryajov 2022-03-28 16:12:25 -06:00
parent d85bb31062
commit 1aa0cfb8dc
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 9 additions and 1 deletions

View File

@ -206,7 +206,7 @@ proc init[TT: Leo](
if parity > buffers:
return err("number of parity buffers cannot exceed number of data buffers!")
if buffers + parity > 65536:
if (buffers + parity) > 65536:
return err("number of parity and data buffers cannot exceed 65536!")
once:

View File

@ -20,6 +20,14 @@ suite "Leopard Parametrization":
LeoEncoder.init(64, 1, 2).error ==
"number of parity buffers cannot exceed number of data buffers!"
test "Should not allow data + parity to exceed 65536":
check:
LeoEncoder.init(64, 65536 + 1, 0).error ==
"number of parity and data buffers cannot exceed 65536!"
LeoEncoder.init(64, 32768 + 1, 32768).error ==
"number of parity and data buffers cannot exceed 65536!"
test "Should not allow encoding with invalid data buffer counts":
var
leo = LeoEncoder.init(64, 4, 2).tryGet()