package org.invisibletech; import static org.junit.Assert.*; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; public class CanDetermineSignTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void shouldRaiseException_Given_NaNDouble() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("NaN"); IndicateSign.signOf(Double.NaN); } @Test public void shouldReturnSign_Given_ZerosDouble() { assertEquals(-1, IndicateSign.signOf(-0.0)); assertEquals(1, IndicateSign.signOf(0.0)); } @Test public void shouldReturnSign_Given_DoubleInfinities() { assertEquals(1, IndicateSign.signOf(Double.POSITIVE_INFINITY)); assertEquals(-1, IndicateSign.signOf(Double.NEGATIVE_INFINITY)); } @Test public void shouldReturnSign_Given_Longs() { assertEquals(1, IndicateSign.signOf(Long.MAX_VALUE)); assertEquals(-1, IndicateSign.signOf(Long.MIN_VALUE)); } }