Compare commits
No commits in common. "fe89cf76af31c9dbec5e2562ab29f690af46dc62" and "ec0c41975dd8e387559b5b49f9eb9e99c14afeb2" have entirely different histories.
fe89cf76af
...
ec0c41975d
@ -122,6 +122,7 @@ public class Board {
|
||||
*
|
||||
* @param first the first index of the values being swapped
|
||||
* @param second the second index of the values being swapped
|
||||
* @return if the values were swapped or not.
|
||||
*/
|
||||
public void swap(int first, int second) {
|
||||
int temp = this.pieces[first];
|
||||
|
75
src/Assignments/A1/tests/Piece/TestConstructor.java
Normal file
75
src/Assignments/A1/tests/Piece/TestConstructor.java
Normal file
@ -0,0 +1,75 @@
|
||||
package Assignments.A1.tests.Piece;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import Assignments.A1.models.Piece;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the constructor for Piece.java.
|
||||
*
|
||||
* @author Jonathan Turner
|
||||
* @version Spring 2024
|
||||
*/
|
||||
public class TestConstructor {
|
||||
|
||||
@Test
|
||||
public void testZeroValue() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Piece(5, 0);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneValue() {
|
||||
Piece test = new Piece(5, 1);
|
||||
assertEquals(1, test.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEightValue() {
|
||||
Piece test = new Piece(5, 8);
|
||||
assertEquals(8, test.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNineValue() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Piece(5, 9);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNegativeLoc() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Piece(-1, 5);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZeroLoc() {
|
||||
Piece test = new Piece(0, 5);
|
||||
assertEquals(0, test.getLoc());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEightLoc() {
|
||||
Piece test = new Piece(8, 5);
|
||||
assertEquals(8, test.getLoc());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNineLoc() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Piece(9, 5);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void validParams() {
|
||||
Piece test = new Piece(3, 6);
|
||||
assertEquals(3, test.getLoc());
|
||||
assertEquals(6, test.getValue());
|
||||
}
|
||||
|
||||
}
|
60
src/Assignments/A1/tests/Piece/TestMoveTo.java
Normal file
60
src/Assignments/A1/tests/Piece/TestMoveTo.java
Normal file
@ -0,0 +1,60 @@
|
||||
package Assignments.A1.tests.Piece;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import Assignments.A1.models.Piece;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the moveTo() for Piece.java.
|
||||
*
|
||||
* @author Jonathan Turner
|
||||
* @version Spring 2024
|
||||
*/
|
||||
public class TestMoveTo {
|
||||
|
||||
@Test
|
||||
public void testNegativeMove() {
|
||||
Piece test = new Piece(3, 5);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
test.moveTo(-1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZeroMove() {
|
||||
Piece test = new Piece(3, 5);
|
||||
test.moveTo(0);
|
||||
assertEquals(0, test.getLoc());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEightMove() {
|
||||
Piece test = new Piece(5, 5);
|
||||
test.moveTo(8);
|
||||
assertEquals(8, test.getLoc());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNineMove() {
|
||||
Piece test = new Piece(3, 5);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
test.moveTo(9);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MoveToSameLocation() {
|
||||
Piece test = new Piece(3, 5);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
test.moveTo(3);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ValidMove() {
|
||||
Piece test = new Piece(3, 5);
|
||||
test.moveTo(4);
|
||||
assertEquals(4, test.getLoc());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user