From cd8838ff0d94214435becd8f9db263836b55cb7e Mon Sep 17 00:00:00 2001 From: DieterHolz Date: Mon, 24 Jul 2023 12:42:59 +0200 Subject: [PATCH] 'isOn()' added to 'SimpleLed' --- src/main/java/com/pi4j/catalog/components/SimpleLed.java | 4 ++++ src/test/java/com/pi4j/catalog/components/SimpleLedTest.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/pi4j/catalog/components/SimpleLed.java b/src/main/java/com/pi4j/catalog/components/SimpleLed.java index 9b5b5a6..56f5cde 100644 --- a/src/main/java/com/pi4j/catalog/components/SimpleLed.java +++ b/src/main/java/com/pi4j/catalog/components/SimpleLed.java @@ -32,6 +32,10 @@ public void on() { digitalOutput.on(); } + public boolean isOn(){ + return digitalOutput.isOn(); + } + /** * Sets the LED to off */ diff --git a/src/test/java/com/pi4j/catalog/components/SimpleLedTest.java b/src/test/java/com/pi4j/catalog/components/SimpleLedTest.java index 9a8b70a..76e597b 100644 --- a/src/test/java/com/pi4j/catalog/components/SimpleLedTest.java +++ b/src/test/java/com/pi4j/catalog/components/SimpleLedTest.java @@ -9,7 +9,7 @@ import com.pi4j.catalog.ComponentTest; import com.pi4j.catalog.components.base.PIN; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class SimpleLedTest extends ComponentTest { @@ -34,6 +34,7 @@ public void testOn() { //then assertEquals(DigitalState.HIGH, digitalOutput.state()); + assertTrue(led.isOn()); } @Test @@ -43,6 +44,7 @@ public void testOff() { //then assertEquals(DigitalState.LOW, digitalOutput.state()); + assertFalse(led.isOn()); }