Trying to get everything to build with JUnit5
This commit is contained in:
parent
2ca00a4fa5
commit
336d85c4cc
@ -191,11 +191,11 @@ subprojects {
|
|||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
srcDir projectDir
|
srcDir projectDir
|
||||||
exclude "*Test.java"
|
// exclude "*Test.java"
|
||||||
exclude "*Tests.java"
|
exclude "*Tests.java"
|
||||||
exclude "*JUnit.java"
|
exclude "*JUnit.java"
|
||||||
exclude "StringInverter*.java"
|
exclude "StringInverter*.java"
|
||||||
exclude "Queue.java"
|
// exclude "Queue.java"
|
||||||
}
|
}
|
||||||
resources {
|
resources {
|
||||||
srcDir projectDir
|
srcDir projectDir
|
||||||
@ -207,11 +207,11 @@ subprojects {
|
|||||||
srcDir projectDir
|
srcDir projectDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test {
|
/* test {
|
||||||
java {
|
java {
|
||||||
srcDir projectDir
|
srcDir projectDir
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*test {
|
/*test {
|
||||||
|
5
generics/Amphibian.java
Normal file
5
generics/Amphibian.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// generics/Amphibian.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
public class Amphibian {}
|
@ -6,29 +6,6 @@ import java.util.*;
|
|||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
import onjava.*;
|
import onjava.*;
|
||||||
|
|
||||||
class Shape {
|
|
||||||
private static long counter = 0;
|
|
||||||
private final long id = counter++;
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getClass().getSimpleName() + " " + id;
|
|
||||||
}
|
|
||||||
public void rotate() {
|
|
||||||
System.out.println(this + " rotate");
|
|
||||||
}
|
|
||||||
public void resize(int newSize) {
|
|
||||||
System.out.println(this + " resize " + newSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Square extends Shape {}
|
|
||||||
|
|
||||||
class FilledList<T> extends ArrayList<T> {
|
|
||||||
public FilledList(Supplier<T> gen, int size) {
|
|
||||||
Suppliers.fill(this, gen, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ApplyTest {
|
public class ApplyTest {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
List<Shape> shapes =
|
List<Shape> shapes =
|
||||||
|
28
generics/FilledList.java
Normal file
28
generics/FilledList.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// generics/FilledList.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
import onjava.*;
|
||||||
|
|
||||||
|
class FilledList<T> extends ArrayList<T> {
|
||||||
|
public FilledList(Supplier<T> gen, int size) {
|
||||||
|
Suppliers.fill(this, gen, size);
|
||||||
|
}
|
||||||
|
public FilledList(T t, int size) {
|
||||||
|
for(int i = 0; i < size; i++)
|
||||||
|
this.add(t);
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<String> list = new FilledList<>("Hello", 4);
|
||||||
|
System.out.println(list);
|
||||||
|
// Supplier version:
|
||||||
|
List<Integer> ilist = new FilledList<>(() -> 47, 4);
|
||||||
|
System.out.println(ilist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Output:
|
||||||
|
[Hello, Hello, Hello, Hello]
|
||||||
|
[47, 47, 47, 47]
|
||||||
|
*/
|
@ -1,23 +0,0 @@
|
|||||||
// generics/FilledListMaker.java
|
|
||||||
// (c)2016 MindView LLC: see Copyright.txt
|
|
||||||
// We make no guarantees that this code is fit for any purpose.
|
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class FilledListMaker<T> {
|
|
||||||
List<T> create(T t, int n) {
|
|
||||||
List<T> result = new ArrayList<>();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
result.add(t);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
FilledListMaker<String> stringMaker =
|
|
||||||
new FilledListMaker<>();
|
|
||||||
List<String> list = stringMaker.create("Hello", 4);
|
|
||||||
System.out.println(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Output:
|
|
||||||
[Hello, Hello, Hello, Hello]
|
|
||||||
*/
|
|
@ -3,6 +3,7 @@
|
|||||||
// We make no guarantees that this code is fit for any purpose.
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
// {CompileTimeError} (Will not compile)
|
// {CompileTimeError} (Will not compile)
|
||||||
|
package generics;
|
||||||
|
|
||||||
interface Payable<T> {}
|
interface Payable<T> {}
|
||||||
|
|
||||||
|
19
generics/Shape.java
Normal file
19
generics/Shape.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// generics/Shape.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
|
||||||
|
public class Shape {
|
||||||
|
private static long counter = 0;
|
||||||
|
private final long id = counter++;
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getClass().getSimpleName() + " " + id;
|
||||||
|
}
|
||||||
|
public void rotate() {
|
||||||
|
System.out.println(this + " rotate");
|
||||||
|
}
|
||||||
|
public void resize(int newSize) {
|
||||||
|
System.out.println(this + " resize " + newSize);
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
// (c)2016 MindView LLC: see Copyright.txt
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
// We make no guarantees that this code is fit for any purpose.
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
// A different kind of collection that is Iterable
|
// A different kind of Iterable collection
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class SimpleQueue<T> implements Iterable<T> {
|
public class SimpleQueue<T> implements Iterable<T> {
|
||||||
|
5
generics/Square.java
Normal file
5
generics/Square.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// generics/Square.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
public class Square extends Shape {}
|
@ -4,9 +4,6 @@
|
|||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
import onjava.*;
|
import onjava.*;
|
||||||
|
|
||||||
class Amphibian {}
|
|
||||||
class Vehicle {}
|
|
||||||
|
|
||||||
public class TupleTest {
|
public class TupleTest {
|
||||||
static Tuple2<String, Integer> f() {
|
static Tuple2<String, Integer> f() {
|
||||||
// Autoboxing converts the int to Integer:
|
// Autoboxing converts the int to Integer:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// We make no guarantees that this code is fit for any purpose.
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
// {CompileTimeError} (Will not compile)
|
// {CompileTimeError} (Will not compile)
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class UseList<W, T> {
|
public class UseList<W, T> {
|
||||||
void f(List<T> v) {}
|
void f(List<T> v) {}
|
||||||
|
5
generics/Vehicle.java
Normal file
5
generics/Vehicle.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// generics/Vehicle.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
public class Vehicle {}
|
@ -1,125 +0,0 @@
|
|||||||
// references/DeepCopy.java
|
|
||||||
// (c)2016 MindView LLC: see Copyright.txt
|
|
||||||
// We make no guarantees that this code is fit for any purpose.
|
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
|
||||||
// Cloning a composed object
|
|
||||||
// (Install libraries from junit.org)
|
|
||||||
import org.junit.jupiter.api.*;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class DepthReading implements Cloneable {
|
|
||||||
private double depth;
|
|
||||||
public DepthReading(double depth) {
|
|
||||||
this.depth = depth;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public DepthReading clone() {
|
|
||||||
try {
|
|
||||||
return (DepthReading)super.clone();
|
|
||||||
} catch(CloneNotSupportedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public double getDepth() { return depth; }
|
|
||||||
public void setDepth(double depth) {
|
|
||||||
this.depth = depth;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.valueOf(depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TemperatureReading implements Cloneable {
|
|
||||||
private long time;
|
|
||||||
private double temperature;
|
|
||||||
public TemperatureReading(double temperature) {
|
|
||||||
time = System.currentTimeMillis();
|
|
||||||
this.temperature = temperature;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public TemperatureReading clone() {
|
|
||||||
try {
|
|
||||||
return (TemperatureReading)super.clone();
|
|
||||||
} catch(CloneNotSupportedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public double getTemperature() {
|
|
||||||
return temperature;
|
|
||||||
}
|
|
||||||
public void setTemperature(double temp) {
|
|
||||||
this.temperature = temp;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.valueOf(temperature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class OceanReading implements Cloneable {
|
|
||||||
private DepthReading depth;
|
|
||||||
private TemperatureReading temperature;
|
|
||||||
public
|
|
||||||
OceanReading(double tdata, double ddata) {
|
|
||||||
temperature = new TemperatureReading(tdata);
|
|
||||||
depth = new DepthReading(ddata);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public OceanReading clone() {
|
|
||||||
OceanReading or = null;
|
|
||||||
try {
|
|
||||||
or = (OceanReading)super.clone();
|
|
||||||
} catch(CloneNotSupportedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
// Must clone references:
|
|
||||||
or.depth = (DepthReading)or.depth.clone();
|
|
||||||
or.temperature =
|
|
||||||
(TemperatureReading)or.temperature.clone();
|
|
||||||
return or;
|
|
||||||
}
|
|
||||||
public TemperatureReading getTemperatureReading() {
|
|
||||||
return temperature;
|
|
||||||
}
|
|
||||||
public void
|
|
||||||
setTemperatureReading(TemperatureReading tr) {
|
|
||||||
temperature = tr;
|
|
||||||
}
|
|
||||||
public DepthReading getDepthReading() {
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
public void setDepthReading(DepthReading dr) {
|
|
||||||
this.depth = dr;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "temperature: " + temperature +
|
|
||||||
", depth: " + depth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DeepCopy {
|
|
||||||
@Test
|
|
||||||
public void testClone() {
|
|
||||||
OceanReading reading =
|
|
||||||
new OceanReading(33.9, 100.5);
|
|
||||||
// Now clone it:
|
|
||||||
OceanReading clone = reading.clone();
|
|
||||||
TemperatureReading tr =
|
|
||||||
clone.getTemperatureReading();
|
|
||||||
tr.setTemperature(tr.getTemperature() + 1);
|
|
||||||
clone.setTemperatureReading(tr);
|
|
||||||
DepthReading dr = clone.getDepthReading();
|
|
||||||
dr.setDepth(dr.getDepth() + 1);
|
|
||||||
clone.setDepthReading(dr);
|
|
||||||
assertEquals(reading.toString(),
|
|
||||||
"temperature: 33.9, depth: 100.5");
|
|
||||||
assertEquals(clone.toString(),
|
|
||||||
"temperature: 34.9, depth: 101.5");
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
org.junit.runner.JUnitCore.runClasses(
|
|
||||||
DeepCopy.class);
|
|
||||||
}
|
|
||||||
}
|
|
28
references/DeepCopyTest.java
Normal file
28
references/DeepCopyTest.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// references/DeepCopyTest.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
package references;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class DeepCopyTest {
|
||||||
|
@Test
|
||||||
|
public void testClone() {
|
||||||
|
OceanReading reading =
|
||||||
|
new OceanReading(33.9, 100.5);
|
||||||
|
// Now clone it:
|
||||||
|
OceanReading clone = reading.clone();
|
||||||
|
TemperatureReading tr =
|
||||||
|
clone.getTemperatureReading();
|
||||||
|
tr.setTemperature(tr.getTemperature() + 1);
|
||||||
|
clone.setTemperatureReading(tr);
|
||||||
|
DepthReading dr = clone.getDepthReading();
|
||||||
|
dr.setDepth(dr.getDepth() + 1);
|
||||||
|
clone.setDepthReading(dr);
|
||||||
|
assertEquals(reading.toString(),
|
||||||
|
"temperature: 33.9, depth: 100.5");
|
||||||
|
assertEquals(clone.toString(),
|
||||||
|
"temperature: 34.9, depth: 101.5");
|
||||||
|
}
|
||||||
|
}
|
29
references/DepthReading.java
Normal file
29
references/DepthReading.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// references/DepthReading.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
// Cloning a composed object
|
||||||
|
package references;
|
||||||
|
|
||||||
|
public class DepthReading implements Cloneable {
|
||||||
|
private double depth;
|
||||||
|
public DepthReading(double depth) {
|
||||||
|
this.depth = depth;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DepthReading clone() {
|
||||||
|
try {
|
||||||
|
return (DepthReading)super.clone();
|
||||||
|
} catch(CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double getDepth() { return depth; }
|
||||||
|
public void setDepth(double depth) {
|
||||||
|
this.depth = depth;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(depth);
|
||||||
|
}
|
||||||
|
}
|
48
references/OceanReading.java
Normal file
48
references/OceanReading.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// references/OceanReading.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
// Cloning a composed object
|
||||||
|
package references;
|
||||||
|
|
||||||
|
public class OceanReading implements Cloneable {
|
||||||
|
private DepthReading depth;
|
||||||
|
private TemperatureReading temperature;
|
||||||
|
public
|
||||||
|
OceanReading(double tdata, double ddata) {
|
||||||
|
temperature = new TemperatureReading(tdata);
|
||||||
|
depth = new DepthReading(ddata);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public OceanReading clone() {
|
||||||
|
OceanReading or = null;
|
||||||
|
try {
|
||||||
|
or = (OceanReading)super.clone();
|
||||||
|
} catch(CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// Must clone references:
|
||||||
|
or.depth = (DepthReading)or.depth.clone();
|
||||||
|
or.temperature =
|
||||||
|
(TemperatureReading)or.temperature.clone();
|
||||||
|
return or;
|
||||||
|
}
|
||||||
|
public TemperatureReading getTemperatureReading() {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
public void
|
||||||
|
setTemperatureReading(TemperatureReading tr) {
|
||||||
|
temperature = tr;
|
||||||
|
}
|
||||||
|
public DepthReading getDepthReading() {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
public void setDepthReading(DepthReading dr) {
|
||||||
|
this.depth = dr;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "temperature: " + temperature +
|
||||||
|
", depth: " + depth;
|
||||||
|
}
|
||||||
|
}
|
33
references/TemperatureReading.java
Normal file
33
references/TemperatureReading.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// references/TemperatureReading.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
// Cloning a composed object
|
||||||
|
package references;
|
||||||
|
|
||||||
|
public class TemperatureReading implements Cloneable {
|
||||||
|
private long time;
|
||||||
|
private double temperature;
|
||||||
|
public TemperatureReading(double temperature) {
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
this.temperature = temperature;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public TemperatureReading clone() {
|
||||||
|
try {
|
||||||
|
return (TemperatureReading)super.clone();
|
||||||
|
} catch(CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double getTemperature() {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
public void setTemperature(double temp) {
|
||||||
|
this.temperature = temp;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(temperature);
|
||||||
|
}
|
||||||
|
}
|
17
verifying/CountedList.java
Normal file
17
verifying/CountedList.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// verifying/CountedList.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
// A List that keeps track of how many
|
||||||
|
// of itself are created.
|
||||||
|
package verifying;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CountedList extends ArrayList<String> {
|
||||||
|
private static int counter = 0;
|
||||||
|
private int id = counter++;
|
||||||
|
public CountedList() {
|
||||||
|
System.out.println("CountedList #" + id);
|
||||||
|
}
|
||||||
|
public int getId() { return id; }
|
||||||
|
}
|
@ -1,25 +1,15 @@
|
|||||||
// verifying/SimpleJUnit.java
|
// verifying/CountedListTest.java
|
||||||
// (c)2016 MindView LLC: see Copyright.txt
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
// We make no guarantees that this code is fit for any purpose.
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
// Simple use of JUnit to test ArrayList
|
// Simple use of JUnit to test CountedList.
|
||||||
package verifying;
|
package verifying;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
//import verifying.CountedList;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
// Keeps track of list objects as they are
|
public class CountedListTest {
|
||||||
// created and cleaned up:
|
|
||||||
class CountedList extends ArrayList<String> {
|
|
||||||
private static int counter = 0;
|
|
||||||
private int id = counter++;
|
|
||||||
public CountedList() {
|
|
||||||
System.out.println("CountedList #" + id);
|
|
||||||
}
|
|
||||||
public int getId() { return id; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SimpleJUnit {
|
|
||||||
private CountedList list;
|
private CountedList list;
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void initialize() {
|
public void initialize() {
|
@ -13,10 +13,6 @@ public class Queue {
|
|||||||
out = 0; // Next gettable object
|
out = 0; // Next gettable object
|
||||||
// Has it wrapped around the circular queue?
|
// Has it wrapped around the circular queue?
|
||||||
private boolean wrapped = false;
|
private boolean wrapped = false;
|
||||||
public static class
|
|
||||||
QueueException extends RuntimeException {
|
|
||||||
public QueueException(String why) { super(why); }
|
|
||||||
}
|
|
||||||
public Queue(int size) {
|
public Queue(int size) {
|
||||||
data = new Object[size];
|
data = new Object[size];
|
||||||
// Must be true after construction:
|
// Must be true after construction:
|
||||||
|
9
verifying/QueueException.java
Normal file
9
verifying/QueueException.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// verifying/QueueException.java
|
||||||
|
// (c)2016 MindView LLC: see Copyright.txt
|
||||||
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
|
package verifying;
|
||||||
|
|
||||||
|
public class QueueException extends RuntimeException {
|
||||||
|
public QueueException(String why) { super(why); }
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
// We make no guarantees that this code is fit for any purpose.
|
// We make no guarantees that this code is fit for any purpose.
|
||||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||||
package verifying;
|
package verifying;
|
||||||
import verifying.Queue.*;
|
import verifying.Queue;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user