Niuslar / Multichannel-Temperature-Control

5 stars 3 forks source link

Fix string parser #98

Closed Niuslar closed 2 years ago

Niuslar commented 2 years ago

After running the tests I noticed some cases where the parser would pass the command to the controllers even when the format should be invalid. There's also a case that breaks the whole application.

Here's a summary of the failed tests:

Command tested Expected Result Result Possible reason
>temperature(arg1, arg2, arg3, ... arg20) [20 values] Malformat Break the app or OK. There's no argument limit check in the parser and it's writing into m_arguments beyond its limit
>temperature(asd25) Malformat Not recognised I think the parser takes that as a string argument
>temperature(1,2,,,,,3,4,5,6,7,8,9,0) Malformat OK. I think the parser is storing empty values as arguments?

Also here's a list of all the commands I tried and their expected results, let me know if you want me to add/change any.

Command Expected Result
>?temperature() COMMAND_OK
>temperature(25) COMMAND_OK
command_00 COMMAND_MALFORMAT
>>temperature(asd25) COMMAND_MALFORMAT OK
temperature(25) COMMAND_MALFORMAT
>temperature(1,2,3,4,5,6,7,8,9,0) COMMAND_OK
>temperature(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0) COMMAND_MALFORMAT
>temperature(1,,,2,3,4,5,6,7,8,9,0) COMMAND_MALFORMAT
>temperature25) COMMAND_MALFORMAT
>temperature(25 COMMAND_MALFORMAT
>temperature(25 24 21 53) COMMAND_MALFORMAT