Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.

Commit

Permalink
new tests-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
timm authored and timm committed Mar 31, 2013
1 parent bcb8c67 commit b0a1782
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
16 changes: 8 additions & 8 deletions firmware/Interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ int decode_command_to_frame(char* token, word* output)
return _MODE_SIMPLE_;
else return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}

if(!strcmp_P(command, command_arc_group))
Expand All @@ -334,7 +334,7 @@ int decode_command_to_frame(char* token, word* output)
return _MODE_SIMPLE_;
else return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}


Expand All @@ -350,7 +350,7 @@ int decode_command_to_frame(char* token, word* output)
else
return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}
}

Expand All @@ -369,23 +369,23 @@ int decode_command_to_frame(char* token, word* output)
else
return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}
}

for(i = 0; i < COUNT_COMMANDS_WITH_PARAM; i++)
{
if(!strcmp_P(command, command_with_param_list[i].key))
{
if(has_param1)
if(has_param1 && has_param2)
{
ret = dali_slave_command(output, (byte)param1, command_with_param_list[i].value);
if(ret == _ERR_OK_)
return command_with_param_list[i].mode;
else
return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}
}

Expand All @@ -396,15 +396,15 @@ int decode_command_to_frame(char* token, word* output)
strcat(groupify, group_postfix);
if(!strcmp(groupify, command))
{
if(has_param1)
if(has_param1 && has_param2)
{
ret = dali_group_command(output, (byte)param1, command_with_param_list[i].value);
if(ret == _ERR_OK_)
return command_with_param_list[i].mode;
else
return ret;
}
return _ERR_PARSE_ERROR_;
return _ERR_PARAMETER_MISSING_;
}
}

Expand Down
1 change: 1 addition & 0 deletions firmware/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C"
#define MAX_BUFFER_LENGTH 256
#define _ERR_PARSE_ERROR_ -253
#define _ERR_BUFFER_FULL_ -254
#define _ERR_PARAMETER_MISSING_ -255
#define _ERR_UNIMPLEMENTED_ -256

inline char nibble_to_ascii(uint8_t nibble);
Expand Down
4 changes: 4 additions & 0 deletions firmware/tests/firmware_test/firmware_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ TEST(ParserTestInvalidInputString, POSITIVE)
EXPECT_EQ(_ERR_PARSE_ERROR_, decode_command_to_frame("up 1000\n", &frame));

EXPECT_EQ(_ERR_UNIMPLEMENTED_, decode_command_to_frame("updown 10 39\n", &frame));

EXPECT_EQ(_ERR_UNIMPLEMENTED_, decode_command_to_frame("up10 39\n", &frame));

EXPECT_EQ(_ERR_PARAMETER_MISSING_, decode_command_to_frame("scene 7\n", &frame));
}


Expand Down

0 comments on commit b0a1782

Please sign in to comment.