Commit a0c660fe43a188b424b1840dcd39f9ccc475a700

Authored by Stéphane Raimbault
1 parent 3593d5ad

Add unit test to read 0 registers

Showing 1 changed file with 12 additions and 2 deletions
tests/unit-test-client.c
@@ -204,7 +204,7 @@ int main(void) @@ -204,7 +204,7 @@ int main(void)
204 rc = modbus_write_registers(ctx, UT_REGISTERS_ADDRESS, 204 rc = modbus_write_registers(ctx, UT_REGISTERS_ADDRESS,
205 UT_REGISTERS_NB_POINTS, 205 UT_REGISTERS_NB_POINTS,
206 UT_REGISTERS_TAB); 206 UT_REGISTERS_TAB);
207 - printf("1/2 modbus_write_registers: "); 207 + printf("1/3 modbus_write_registers: ");
208 if (rc == UT_REGISTERS_NB_POINTS) { 208 if (rc == UT_REGISTERS_NB_POINTS) {
209 printf("OK\n"); 209 printf("OK\n");
210 } else { 210 } else {
@@ -215,7 +215,7 @@ int main(void) @@ -215,7 +215,7 @@ int main(void)
215 rc = modbus_read_registers(ctx, UT_REGISTERS_ADDRESS, 215 rc = modbus_read_registers(ctx, UT_REGISTERS_ADDRESS,
216 UT_REGISTERS_NB_POINTS, 216 UT_REGISTERS_NB_POINTS,
217 tab_rp_registers); 217 tab_rp_registers);
218 - printf("2/2 modbus_read_registers: "); 218 + printf("2/3 modbus_read_registers: ");
219 if (rc != UT_REGISTERS_NB_POINTS) { 219 if (rc != UT_REGISTERS_NB_POINTS) {
220 printf("FAILED (nb points %d)\n", rc); 220 printf("FAILED (nb points %d)\n", rc);
221 goto close; 221 goto close;
@@ -230,6 +230,16 @@ int main(void) @@ -230,6 +230,16 @@ int main(void)
230 } 230 }
231 } 231 }
232 printf("OK\n"); 232 printf("OK\n");
  233 +
  234 + rc = modbus_read_registers(ctx, UT_REGISTERS_ADDRESS,
  235 + 0, tab_rp_registers);
  236 + printf("3/3 modbus_read_registers (0): ");
  237 + if (rc != 0) {
  238 + printf("FAILED (nb points %d)\n", rc);
  239 + goto close;
  240 + }
  241 + printf("OK\n");
  242 +
233 /* End of many registers */ 243 /* End of many registers */
234 244
235 245