| 9 | import static org.junit.Assert.assertNotEquals; |
| 10 | |
| 11 | public class RecordExampleTest { |
| 12 | |
| 13 | @Test(expected = IllegalArgumentException.class) |
| 14 | public void testCtor() { |
| 15 | int i = 1_000_000 + 1; |
| 16 | new RecordExample(i, "yeah", 100500, 0.5f, 5d, new String[]{"Hello", "World!"}, true); |
| 17 | } |
| 18 | |
| 19 | @Test |
| 20 | public void testToString() { |
| 21 | RecordExample r = new RecordExample(42, "yeah", 100500, 0.5f, 5d, new String[]{"Hello", "World!"}, true); |
| 22 | |
| 23 | assertEquals( |
| 24 | "RecordExample[i=42,s=yeah,l=100500,f=0.5,d=5.0,arr=[Ljava.lang.String;@hash,b=true]", |
| 25 | Objects.toString(r).replaceAll(";@[a-f0-9]+", ";@hash") |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | @Test |
| 30 | public void testToStringWithNulls() { |
| 31 | RecordExample r = new RecordExample(42, null, 100500, 0.5f, 5d, null, true); |
| 32 | |
| 33 | assertEquals( |
| 34 | "RecordExample[i=42,s=null,l=100500,f=0.5,d=5.0,arr=null,b=true]", |
| 35 | Objects.toString(r) |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void testEqualsSame() { |
| 41 | RecordExample r = new RecordExample(42, null, 100500, 0.5f, 5d, null, true); |
| 42 | assertEquals(r, r); |
| 43 | } |
| 44 | |
| 45 | @Test |
| 46 | public void testEqualsSameValues() { |
| 47 | String s = "So cool!"; |
| 48 | String[] arr = new String[] { "Hello", "World!"}; |
| 49 | assertEquals( |
| 50 | new RecordExample(42, s, 100500, 0.5f, 5d, arr, true), |
| 51 | new RecordExample(42, s, 100500, 0.5f, 5d, arr, true) |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | @Test |
| 56 | public void testNotEquals() { |
| 57 | assertNotEquals( |
| 58 | new RecordExample(42, "l", 100500, 0.5f, 5d, new String[] { "Hello", "World!"}, true), |
| 59 | new RecordExample(42, "l", 100500, 0.5f, 5d, new String[] { "Hello", "World!"}, true) |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | @Test |
| 64 | public void testHashCodeWithDefaults() { |
| 65 | assertEquals( |
| 66 | intellijStyleHashCode(RecordExample.DUMMY), |
| 67 | Objects.hashCode(RecordExample.DUMMY) |
| 68 | ); |
nothing calls this directly
no outgoing calls
no test coverage detected