From: Bartosz Golaszewski Date: Thu, 8 Aug 2019 15:06:44 +0000 (+0200) Subject: bindings: cxx: tests: extend the test case for global find_line() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=25591339089735d7974da105c4bd6ad059783638;p=qemu-gpiodev%2Flibgpiod.git bindings: cxx: tests: extend the test case for global find_line() Split the test into sections and also test the case where the line is not found. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/cxx/tests/tests-line.cpp b/bindings/cxx/tests/tests-line.cpp index 2684bcb..9b21b95 100644 --- a/bindings/cxx/tests/tests-line.cpp +++ b/bindings/cxx/tests/tests-line.cpp @@ -22,10 +22,19 @@ TEST_CASE("Global find_line() function works", "[line]") { mockup::probe_guard mockup_chips({ 8, 8, 8, 8, 8 }, mockup::FLAG_NAMED_LINES); - auto line = ::gpiod::find_line("gpio-mockup-C-5"); - REQUIRE(line.offset() == 5); - REQUIRE(line.name() == "gpio-mockup-C-5"); - REQUIRE(line.get_chip().label() == "gpio-mockup-C"); + SECTION("line found") + { + auto line = ::gpiod::find_line("gpio-mockup-C-5"); + REQUIRE(line.offset() == 5); + REQUIRE(line.name() == "gpio-mockup-C-5"); + REQUIRE(line.get_chip().label() == "gpio-mockup-C"); + } + + SECTION("line not found") + { + auto line = ::gpiod::find_line("nonexistent-line"); + REQUIRE_FALSE(line); + } } TEST_CASE("Line information can be correctly retrieved", "[line]")