From: Bartosz Golaszewski Date: Wed, 9 May 2018 20:23:14 +0000 (+0200) Subject: bindings: cxx: add test cases for iterators X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ac48e6c3c456eba7c17299c8bf1408ace3d46dda;p=qemu-gpiodev%2Flibgpiod.git bindings: cxx: add test cases for iterators Add simple tests for chip and line iterators. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/cxx/examples/gpiod_cxx_tests.cpp b/bindings/cxx/examples/gpiod_cxx_tests.cpp index 4c6e859..81cf62c 100644 --- a/bindings/cxx/examples/gpiod_cxx_tests.cpp +++ b/bindings/cxx/examples/gpiod_cxx_tests.cpp @@ -440,6 +440,26 @@ void line_event_poll_fd(void) } TEST_CASE(line_event_poll_fd); +void chip_iterator(void) +{ + ::std::cerr << "iterating over all GPIO chips in the system:" << ::std::endl; + + for (auto& it: ::gpiod::make_chip_iter()) + ::std::cerr << it.name() << ::std::endl; +} +TEST_CASE(chip_iterator); + +void line_iterator(void) +{ + ::std::cerr << "iterating over all lines exposed by a GPIO chip:" << ::std::endl; + + ::gpiod::chip chip("gpiochip0"); + + for (auto& it: ::gpiod::line_iter(chip)) + ::std::cerr << it.offset() << ": " << it.name() << ::std::endl; +} +TEST_CASE(line_iterator); + } /* namespace */ int main(int, char **)