From f2ab0dcf22929594ef41d30070bf1ccfed390338 Mon Sep 17 00:00:00 2001 From: 2bllw8 <2bllw8@gmail.com> Date: Thu, 9 Sep 2021 17:13:32 +0200 Subject: [PATCH] Add tests for invalid null arguments --- .../java/exe/bbllw8/either/EitherTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/src/test/java/exe/bbllw8/either/EitherTest.java b/lib/src/test/java/exe/bbllw8/either/EitherTest.java index 590fe14..e264466 100644 --- a/lib/src/test/java/exe/bbllw8/either/EitherTest.java +++ b/lib/src/test/java/exe/bbllw8/either/EitherTest.java @@ -22,6 +22,26 @@ public void leftAndRightNotEqual() { Either.right(2).hashCode()); } + @Test(expected = NullPointerException.class) + public void failOnLeftNull() { + Either.left(null); + } + + @Test(expected = NullPointerException.class) + public void failOnRightNull() { + Either.right(null); + } + + @Test(expected = NullPointerException.class) + public void failOnIffLeftNull() { + Either.iff(true, () -> null, () -> 1); + } + + @Test(expected = NullPointerException.class) + public void failOnIffRightNull() { + Either.iff(false, () -> 0, () -> null); + } + @Test public void consistentEquals() { //noinspection AssertBetweenInconvertibleTypes