mirror of
https://bitbucket.org/Mattrixwv/matrix.git
synced 2025-12-06 23:13:57 -05:00
Bugfixes
Update tests Add javadoc comments
This commit is contained in:
@@ -1,37 +1,55 @@
|
||||
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestInvalidCoordinatesException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-13-23
|
||||
//Modified: 04-13-23
|
||||
//Modified: 08-11-24
|
||||
package com.mattrixwv.matrix.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidCoordinatesException{
|
||||
private String message = "message";
|
||||
private Throwable cause = new Exception();
|
||||
private static final String message = "message";
|
||||
private static final Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructor(){
|
||||
public void testConstructor_default(){
|
||||
InvalidCoordinatesException exception = new InvalidCoordinatesException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidCoordinatesException(message);
|
||||
}
|
||||
@Test
|
||||
public void testConstructor_message(){
|
||||
InvalidCoordinatesException exception = new InvalidCoordinatesException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
}
|
||||
|
||||
exception = new InvalidCoordinatesException(cause);
|
||||
@Test
|
||||
public void testConstructor_cause(){
|
||||
InvalidCoordinatesException exception = new InvalidCoordinatesException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidCoordinatesException(message, cause);
|
||||
}
|
||||
@Test
|
||||
public void testConstructor_messageCause(){
|
||||
InvalidCoordinatesException exception = new InvalidCoordinatesException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructor_elements(){
|
||||
int givenElements = 3;
|
||||
int neededElements = 2;
|
||||
String elementsMessage = "Invalid number of elements " + givenElements + " must be at most " + neededElements;
|
||||
|
||||
InvalidCoordinatesException exception = new InvalidCoordinatesException(givenElements, neededElements);
|
||||
|
||||
assertEquals(elementsMessage, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user