From ac48e6c3c456eba7c17299c8bf1408ace3d46dda Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 9 May 2018 22:23:14 +0200 Subject: [PATCH] bindings: cxx: add test cases for iterators Add simple tests for chip and line iterators. Signed-off-by: Bartosz Golaszewski --- bindings/cxx/examples/gpiod_cxx_tests.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 **) -- 2.30.2