bindings: cxx: add test cases for iterators
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 9 May 2018 20:23:14 +0000 (22:23 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 9 May 2018 20:23:52 +0000 (22:23 +0200)
Add simple tests for chip and line iterators.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/cxx/examples/gpiod_cxx_tests.cpp

index 4c6e859a91afe9613af74c13f0a12b9d0035cd2e..81cf62c16bee81c137c5597560866296b0bf5043 100644 (file)
@@ -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 **)