init and unit tests

This commit is contained in:
2025-12-19 16:58:21 -06:00
commit b178b31cbf
11 changed files with 500 additions and 0 deletions
@@ -0,0 +1,21 @@
package com.softwaresmyth.functions;
import java.util.Optional;
public class OrNot
{
public static void noop(Object... ignored)
{
//do nothing
}
public static <T> T returnNull(Object... ignored)
{
return null;
}
public static <T> Optional<T> returnEmpty(Object... ignored)
{
return Optional.empty();
}
}
@@ -0,0 +1,21 @@
package com.softwaresmyth.functions;
import org.junit.jupiter.api.Test;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
class NoopTest {
@Test
void TestOneArg() {
Consumer<String> toTest = OrNot::noop;
toTest.accept("Ignored");
}
@Test
void TestTwoArg() {
BiConsumer<Double, Boolean> toTest = OrNot::noop;
toTest.accept(0.0, false);
}
}
@@ -0,0 +1,32 @@
package com.softwaresmyth.functions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
class ReturnEmptyTest {
@Test
void TestZeroArgs() {
Supplier<Optional<String>> toTest = OrNot::returnEmpty;
Optional<String> result = toTest.get();
Assertions.assertFalse(result.isPresent());
}
@Test
void TestOneArg() {
Function<Double, Optional<String>> toTest = OrNot::returnEmpty;
Optional<String> result = toTest.apply(0.0);
Assertions.assertFalse(result.isPresent());
}
@Test
void TestTwoArg() {
BiFunction<Double, Boolean, Optional<String>> toTest = OrNot::returnEmpty;
Optional<String> result = toTest.apply(0.0, false);
Assertions.assertFalse(result.isPresent());
}
}
@@ -0,0 +1,32 @@
package com.softwaresmyth.functions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
class ReturnNullTest {
@Test
void TestZeroArgs() {
Supplier<String> toTest = OrNot::returnNull;
String result = toTest.get();
Assertions.assertNull(result);
}
@Test
void TestOneArg() {
Function<Double, String> toTest = OrNot::returnNull;
String result = toTest.apply(0.0);
Assertions.assertNull(result);
}
@Test
void TestTwoArg() {
BiFunction<Double, Boolean, String> toTest = OrNot::returnNull;
String result = toTest.apply(0.0, false);
Assertions.assertNull(result);
}
}