Skip to content

Commit

Permalink
Unit test for baud rate check and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane committed Apr 9, 2014
1 parent b7ed06a commit 93a0598
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/modbus-rtu.c
Expand Up @@ -1148,7 +1148,7 @@ modbus_t* modbus_new_rtu(const char *device,

/* Check baud argument */
if (baud == 0) {
fprintf(stderr, "baud must not be zero\n");
fprintf(stderr, "The baud rate value must not be zero\n");
errno = EINVAL;
return NULL;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/unit-test-client.c
Expand Up @@ -590,7 +590,10 @@ int main(int argc, char *argv[])

/* Test init functions */
printf("\nTEST INVALID INITIALIZATION:\n");
ctx = modbus_new_rtu(NULL, 0, 'A', 0, 0);
ctx = modbus_new_rtu(NULL, 1, 'A', 0, 0);
ASSERT_TRUE(ctx == NULL && errno == EINVAL, "");

ctx = modbus_new_rtu("/dev/dummy", 0, 'A', 0, 0);
ASSERT_TRUE(ctx == NULL && errno == EINVAL, "");

ctx = modbus_new_tcp_pi(NULL, NULL);
Expand Down

0 comments on commit 93a0598

Please sign in to comment.