|
| 1 | +package net.minidev.asm.ex; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 6 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 7 | + |
| 8 | +import org.junit.jupiter.api.Test; |
| 9 | + |
| 10 | +public class NoSuchFieldExceptionTest { |
| 11 | + |
| 12 | + @Test |
| 13 | + public void testDefaultConstructor() { |
| 14 | + NoSuchFieldException exception = new NoSuchFieldException(); |
| 15 | + assertNotNull(exception); |
| 16 | + assertNull(exception.getMessage()); |
| 17 | + assertTrue(exception instanceof RuntimeException); |
| 18 | + } |
| 19 | + |
| 20 | + @Test |
| 21 | + public void testConstructorWithMessage() { |
| 22 | + String message = "Test field not found error"; |
| 23 | + NoSuchFieldException exception = new NoSuchFieldException(message); |
| 24 | + assertNotNull(exception); |
| 25 | + assertEquals(message, exception.getMessage()); |
| 26 | + assertTrue(exception instanceof RuntimeException); |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + public void testConstructorWithNullMessage() { |
| 31 | + NoSuchFieldException exception = new NoSuchFieldException(null); |
| 32 | + assertNotNull(exception); |
| 33 | + assertNull(exception.getMessage()); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testConstructorWithEmptyMessage() { |
| 38 | + String message = ""; |
| 39 | + NoSuchFieldException exception = new NoSuchFieldException(message); |
| 40 | + assertNotNull(exception); |
| 41 | + assertEquals(message, exception.getMessage()); |
| 42 | + } |
| 43 | +} |
0 commit comments