From: Bartosz Golaszewski Date: Sat, 1 Jul 2017 09:07:13 +0000 (+0200) Subject: tests: line: new test case X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2ba2a49c08843f09ba8282e035fe84e445b3a461;p=qemu-gpiodev%2Flibgpiod.git tests: line: new test case Verify that a consumer string over 31 characters long is correctly cropped. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/tests-line.c b/tests/tests-line.c index 3b36a20..617e02b 100644 --- a/tests/tests-line.c +++ b/tests/tests-line.c @@ -89,6 +89,34 @@ TEST_DEFINE(line_consumer, "gpiod_line_consumer() - good", 0, { 8 }); +static void line_consumer_long_string(void) +{ + TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip = NULL; + struct gpiod_line *line; + int status; + + chip = gpiod_chip_open(test_chip_path(0)); + TEST_ASSERT_NOT_NULL(chip); + + line = gpiod_chip_get_line(chip, 0); + TEST_ASSERT_NOT_NULL(line); + + TEST_ASSERT_NULL(gpiod_line_consumer(line)); + + status = gpiod_line_request_input(line, + "consumer string over 32 characters long", + false); + TEST_ASSERT_RET_OK(status); + + TEST_ASSERT(!gpiod_line_needs_update(line)); + TEST_ASSERT_STR_EQ(gpiod_line_consumer(line), + "consumer string over 32 charact"); + TEST_ASSERT_EQ(strlen(gpiod_line_consumer(line)), 31); +} +TEST_DEFINE(line_consumer_long_string, + "gpiod_line_consumer() - long consumer string", + 0, { 8 }); + static void line_request_bulk_output(void) { TEST_CLEANUP(test_close_chip) struct gpiod_chip *chipA = NULL;